]
Gail Badner resolved HHH-5354.
------------------------------
Assignee: Gail Badner
Resolution: Rejected
You probably need to cast one of the columns the same type as the other column. Please use
the user forum for help (
Joining fixed-length CHAR field with VARCHAR field
--------------------------------------------------
Key: HHH-5354
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5354
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.5.3
Environment: Windows XP, JDK 1.6.0_07, Hibernate 3, Oracle 10g
Reporter: Will Sumekar
Assignee: Gail Badner
Attachments: OracleCHAR.java
I join 2 tables on join condition:
table1.col1=table2.col2
col1 is NOT table1's PK, col2 is table1's PK
col1's type is CHAR(20), col2's type is VARCHAR(40)
I use Hibernate's Criteria API and it doesn't recognise the join condition and
gives me 0 row.
I've trimmed the padding spaces by extending UserType but it doesn't work. Seems
that it only works for retrieving a CHAR field, not joining it to another field.
Code:
Criteria pq = session.createCriteria(Devices.class).createAlias("PrisProduct",
"pp");
pq.add(Restrictions.eq(field, value.trim()));
Collection pc = pq.list();
The Devices.hbm.xml excerpt:
<property name="dieCode"
type="com.st.wma.datalayer.hibernate.util.OracleCHAR">
<column name="DIE_CODE" length="20"
not-null="true" unique="true" />
</property>
<many-to-one name="PrisProduct"
class="com.st.wma.datalayer.hibernate.model.PrisProduct"
column="DIE_CODE" not-null="true" insert="false"
update="false">
</many-to-one>
The PrisProduct.hbm.xml excerpt:
<set name="devices" table="DEVICES">
<key column="CAM_PRODUCT"/>
<one-to-many
class="com.st.wma.datalayer.hibernate.model.Devices"/>
</set>
OracleCHAR code is attached.
It's not in my capacity to change the DB schema so I can't change the CHAR to
VARCHAR.
environment: Windows XP, JDK 1.6.0_07, Hibernate 3, Oracle 10g
Thanks!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: