I am looking for an example on how to use the <whereparams></whereparams> which belongs to <update></update>, but I couldn't find anything (even in the official documentation).
any help is much appreciated.thanks.
An example usage is
<update tableName="updateTest">
<column name="varcharColumn" value="new column 1 value"/>
<column name="dateCol" valueDate="2008-01-01"/>
<column name="intCol" valueNumeric="11"/>
<where>id=:value</where>
<whereParams>
<param valueNumeric="134" />
</whereParams>
</update>
where the :value statements in the <where> block is replaced with the values in the `param' blocks. If there are multiple :value statements they are replaced in order within the where clause.
However, looking at the code, it looks like the usage of whereParams is not well used or integrated. Perhaps I am missing where it is being picked up, but it may not even be working outside blob/clob updating.
Give it a try and see if it works for you, otherwise I'd say stick with the standard where block until support is improved.
I support #nathan-voxland answer. Seems he is very good in liquibase.
But i want share one more where/whereParams example with additional ability (you can use whereParams block for field names also):
<where>:name=:value and :name=:value</where>
<whereParams>
<param name="id" valueNumeric="21"/>
<param name="name" value="bob"/>
</whereParams>
I believe my example do not need more explanations.
In response to Nathan's comment about lack of support for this feature, I can confirm that it is working well in version 3.3.2. When he commented liquibase was at version 3.1.1. Maybe support was improved somewhere between 3.1.1 and 3.3.2, but from a quick browse through the change log I don't see which version this would have been.
The docs at http://www.liquibase.org/documentation/changes/update.html are sparse, but basically the contains a SQL-like where clause. So if you would normally do something like
UPDATE cat.person SET address = NULL WHERE id=12;
Then your changeset would look like this:
<changeSet author="liquibase-docs" id="update-example">
<update catalogName="cat"
schemaName="public"
tableName="person">
<column name="address" type="varchar(255)"/>
<where>id=12</where>
</update>
</changeSet>
Related
Today I found the same http request to the backend api server, sometimes it could fetch the article, sometimes it could not fetch the article, this is my code:
Article article = articleMapper.selectByPrimaryKey(id);
and this is the code generate automaticlly using MyBatis Generator:
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - #mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from article
where id = #{id,jdbcType=BIGINT}
</select>
the same http request, with the same article id. I do not know where is going wrong.My PostgreSQL version is 13. And this is my auto generate xml config:
<table tableName="article"
enableCountByExample="true"
enableUpdateByExample="true"
enableDeleteByExample="true"
enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="JDBC" identity="true" />
</table>
any clue to figure out what wrong with the code? I am a newbie about PostgreSQL as backend database.
Does the article with the id you're querying for exist? Yes, I am sure the ID exists.
Could there be concurrent modifications? No, It is impossible. I will never edit the article after write into database. No transactions,The article is an old article.
I have wanting to import data from a table and index it using solr..
I am using solr-tomcat admin panel.
But whenever I query it returns to me only the id's and value.
I have also tried adding FIELDS to fl , but that also does not help.
here is my data-config.xml file:
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/{DB_NAME}"
user="{DB_USER}"
password="{DB_PASSS}"
/>
<document>
<entity name="id" query="select s3_location,file_name from video">
<field column="s3_location" name="s3_location"/>
<field column="file_name" name="file_name"/>
</entity>
</document>
</dataConfig>
Is there any way to get the above s3_location and file_name fields also.
You need to specify the actual field names in the fl parameter or use * to indicate all fields. Also, please note that the fields must have been defined with stored=true in your schema.xml file for them to be returned/visible during a query.
fl=id,s3_location,file_name
fl=*
Are you sure you are importing the data at all? If you start with empty index, do you get anything?
The reason I ask is because you are not mapping the id field explicitly. Now, I believe there is implicit mapping of the fields by Jdbc data source based on names, but relying on it is risky when you are just starting.
Otherwise, like Paige said, make sure you defined those fields in your schema and that they are actually stored.
I have changed the code of Orbeon Form Builder to add a new input field in dialog-form-settings.xbl:
<xf:input ref="category" id="fb-category-input" xxf:autocomplete="off">
<xf:label>Category</xf:label>
<xf:hint>input Category</xf:hint>
</xf:input>
<!-- Dispatch event with result -->
<xf:dispatch name="fb-update-metadata" targetid="fb-dialog-form-settings">
<xf:property name="app" value="instance()/app"/>
<xf:property name="form" value="instance()/form"/>
<!-- Add By Haibpl -->
<xf:property name="category" value="instance()/category"/>
<!-- End Add -->
<xf:property name="title" value="instance()/title"/>
<xf:property name="description" value="instance()/description"/>
<xf:property name="logo" value="instance()/logo"/>
<xf:property name="mode" value="instance()/mode"/>
</xf:dispatch>
In crud.xpl, how can i get value of category like app (/request/app)?
My recommendation most likely won't be what you're looking for, but here it is anyway: try to avoid making changes to Form Builder and Form Runner. Those changes can be hard to port to new versions of Orbeon Forms, make it hard to upgrade, and then, if you are stuck with an older version, to get support for it.
Also, while you can get help from Orbeon for these type of customizations under a Dev Support subscription, customization are not covered by PE subscriptions, and you won't get much help in the community either, as this isn't something we'd like to encourage.
So, have you thought of using the "app" as the "category"? And if you need both an "app" and a "category", have you thought about putting both in the "app" field with say a dash in between? E.g. hr-applications, instead of having an app hr and a category application?
This doesn't seem to work:
<property name="foo" value="\n bar \n"/>
I use the property value in the body of an e-mail message (which is sent as plain text):
<mail ...>
<message>some text${foo}</message>
and I get literal "\n" in the e-mail output.
These all work for me:
<property name="foo" value="bar${line.separator}bazz"/>
<property name="foo">bar
bazz2</property>
<property name="foo" value="bar
bazz"/>
You want ${line.separator}. See this post for an example. Also, the Ant echo task manual page has an example using ${line.separator}.
By using ${line.separator} you're simply using a Java system property. You can read up on the list of system properties here, and here is Ant's manual page on Properties.
I have some 10 tables with the following schema
ID
Year
Code
Section
Period
Date
Status
Each table has a name data_1, data_2 and so on. Now I want to write Hibernate mapping for these tables. As all these tables have the same schema with only the names different I wrote a POJO file with data as super class and all the other 10 classes inheriting it.
What do I do now with the hbm files? Do I have to write one hbm file for each table? I tried the union-subclass, but somehow I couldn't get it right. I am getting a lot of unexplained errors in Hibernate.
How can I write the Hibernate mapping in this type of scenario? I am a starter in Hibernate and please note that the choice of database design is not in my hands. I have 30 such similar type of hierarchies.
First you must understand that there is no such thing as inheritance in relational database system. But there are strategies to map the inheritance structure to the database.
Check out the hibernate documentation at http://docs.jboss.org/hibernate/core/3.3/reference/en/html/inheritance.html
As far as I understand, your strategy is "Table per concrete class"
First of all you need to choose what type of strategy you want for the inheritance. There are a few options.
Have a look at this link here where it describes a little about inheritance in JPA. Hibernate supports JPA, so the mappings should be the same, ie:
Note however that this is the mapping type for EclipseLink
<entity name="Project" class="Project" access="FIELD">
<table name="PROJECT"/>
<inheritance strategy="JOINED"/>
<discriminator-value>P</discriminator-value>
<discriminator-column name="TYPE"/>
<attributes>
<id name="id"><column name="ID"/> </id>
</attributes>
</entity>
<entity name="LargeProject" class="LargeProject" access="FIELD">
<table name="L_PROJECT"/>
<discriminator-value>L</discriminator-value>
</entity>