[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5354) Joining fixed-length CHAR field with VARCHAR field

Will Sumekar (JIRA) noreply at atlassian.com
Tue Jul 6 22:25:13 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37657#action_37657 ] 

Will Sumekar commented on HHH-5354:
-----------------------------------

Hi Gail
Thanks for your prompt reply. 

As you can see in the attached code, the returned class of type OracleCHAR is String, the same as the other field. So I think casting is not necessary. 

I have opened a thread in the user forum, but to no replies. You may reply there. The link is: 
https://forums.hibernate.org/viewtopic.php?f=1&t=1005648&sid=84ecc2379ec19874e0380002294a5a63

Thanks. 



> 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: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list