The parameters passed through queryMap of valuelist are of the string type by default. In hql of the valuelist configuration file, an error is returned if this value is directly assigned to an integer field. We generally use transformation functions in hql for processing, as shown below:
Copy codeThe Code is as follows:
<Entry key = "areasInfoAdapter">
<Bean parent = "maid">
<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">
<Value>
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 }~ /
Order by tb. code asc
</Value>
</Property>
<Property name = "defaultFocusPropertyObjectAlias"> <value> vo </value> </property>
<Property name = "maxRowsForFocus"> <value> 160000 </value> </property>
<Property name = "removeEmptyStrings"> <value> true </value> </property>
</Bean>
</Entry>
This method is troublesome. function processing must be added to all integer fields, and function incompatibility may occur during database migration. You can use the ValueList configuration to uniformly set integer fields. valuelist will transform the configured parameters before assembling SQL statements. As follows:
Copy codeThe Code is 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">
<Map>
<Entry key = "uId"> <ref bean = "integerSetterHql"/> </entry>
<Entry key = "oId"> <ref bean = "integerSetterHql"/> </entry>
</Map>
</Property>
</Bean>