Steve:
Below is the SQL generated by the query:
Hibernate: select this_.RVN_CD as RVN1_0_, this_.RVN_EFF_DT as RVN2_0_0_, this_.RVN_TERM_DT as RVN3_0_0_, this_.RVN_DFL_DT_IND as RVN4_0_0_, this_.RVN_CTG_CD as RVN5_0_0_, this_.RVN_FU_DSC as RVN6_0_0_, this_.RVN_SUBC_STD_ABB as RVN7_0_0_, this_.CRE_USE_ID as CRE8_0_0_, this_.CRE_TS as CRE9_0_0_, this_.LAST_UPD_USE_ID as LAST10_0_0_, this_.LAST_UPD_TS as LAST11_0_0_, this_.DEL_IND as DEL12_0_0_ from IBC.IBC_REVENUE this_ where lcase(this_.RVN_CD) like ? order by this_.RVN_CD asc
Regarding the Criteria definition, I have a utility helper class that creates the Criteria based on form values and query options selected (i.e. Contains, Begins With, Ends With, etc).
For this particular query, the Criteria for the problematic field is set as follows...
Code:
Criteria crit = sess.createCriteria(<some class>);
crit.add(
Expression.or(
Expression.ilike(key,"% " + value + "%"),
Expression.ilike(key,value + "%")));
where
key = the field to search on
value = field value (in this case 'zz')
The field in question is an id field in the mapping. When and id field has a "special character" (in this case 'Ð'), it will return a duplicate in the Criteria.list() but will not display the special character in the returned results. That same "special character" field value is fine to search on and display in non-id fields (i.e. property for example).
Below is my mapping for the class this is causing problems in, which seems like a very straightforward, simple mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.ibx.ccs.hibernate.ComplexMedicalRevenue" schema="IBC" table="IBC_REVENUE">
<id name="revenueCode" column="RVN_CD" type="string" length="4"><generator class="assigned"/></id>
<property name="effectiveDate" column="RVN_EFF_DT" type="date" not-null="true" length="10"/>
<property name="terminationDate" column="RVN_TERM_DT" type="date" not-null="false" length="10"/>
<property name="defaultEffectiveDateIndicator" column="RVN_DFL_DT_IND" type="string" not-null="true" length="1" />
<property name="categoryCode" column="RVN_CTG_CD" type="string" not-null="true" length="1" />
<property name="fullDescription" column="RVN_FU_DSC" type="string" not-null="true" length="500"/>
<property name="subcategoryStandardAbbreviation" column="RVN_SUBC_STD_ABB" type="string" not-null="true" length="100"/>
<property name="createUser" column="CRE_USE_ID" type="string" not-null="true" length="8"/>
<property name="createTimestamp" column="CRE_TS" type="timestamp" not-null="true" length="26" />
<property name="lastUpdateUser" column="LAST_UPD_USE_ID" type="string" not-null="true" length="8"/>
<property name="lastUpdateTimestamp" column="LAST_UPD_TS" type="timestamp" not-null="true" length="26"/>
<property name="deleteIndicator" column="DEL_IND" type="string" not-null="true" length="1"/>
</class>
</hibernate-mapping>
Running a similar select in WinSQL (or even a command prompt DB2 shell) returns the correct number of rows (3 instead of 4 as Hibernate does) with the correct values for the id field (including the special character Ð, unlike Hibernate which returns zzz instead of zzzÐ).
Let me know if you need any additional information, or can spot anything in the SQL or code above.