How to automatically implement integer parameter conversion of HQL statement in ValueList by configuration

Source: Internet
Author: User

The parameters passed through the ValueList QueryMap are all string types, and in the hql of the ValueList configuration file, a field that assigns the value directly to an integer will be an error. In general, we will use transformation functions in HQL for processing, as follows:

Copy Code code as follows:

<entry key= "Areasinfoadapter" >

<bean parent= "Abstracthibernate30adapter" >

<property name= "Defaultnumberperpage" ><value>19</value></property>

<property name= "Statementbuilder" ><ref bean= "statementbuilderhql"/></property>

<property name= "Defaultsortcolumn" ><value>id</value></property>

<property name= "defaultsortdirection" ><value>desc</value></property>

<property name= "HQL" >


from Com.berheley.hcms.persistence.model.TBaseAreas as TB

where tb.status= ' 1 '

/~hid:and tb.hid = to_number{hid} ~/

/~oid:and tb.oid = to_number{oid} ~/




<property name= "Defaultfocuspropertyobjectalias" ><value>vo</value></property>

<property name= "Maxrowsforfocus" ><value>160000</value></property>

<property name= "removeemptystrings" ><value>true</value></property>



This method is more troublesome, in all the integer fields need to add function processing, and the database migration will be incompatible with the function of the problem. You can use the ValueList configuration to unify the fields of an integral type, and valuelist the configured parameters before assembling the SQL. As follows:

Copy Code code as follows:

<bean id= "integersetterhql" class= "Net.mlw.vlh.adapter.hibernate3.util.setter.IntegerSetter" ></ Bean>
<bean id= "statementbuilderhql" class= "Net.mlw.vlh.adapter.hibernate3.util.StatementBuilder" >
<property name= "Setters"
<entry key= "uId" ><ref bean= "integersetterhql"/> </entry>
<entry key= "oId" ><ref bean= "integersetterhql"/></ENTRY>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.