[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5135) Prefix is missed in HQL query for property mapped to column 'TO_DATE' on Oracle 10g

Peter Pedron (JIRA) noreply at atlassian.com
Mon May 3 05:15:49 EDT 2010


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

Peter Pedron commented on HHH-5135:
-----------------------------------

I also get this SQL ambiguous error, if I map two attributes of Java class with the SAME type with a @OneToOne-relationship:

@Entity(...)
public class X {

@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER, targetEntity=DateImpl.class)
private Y attribute1;

@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER, targetEntity=DateImpl.class)
private  Y atribute2;
}

Could fix it with the @Fetch annotation : @org.hinernate.annotations.Fetch(FetchMode.SELECT)
Working with:
+hibernate-core 3.5.1-Final
+hibernate-annotations 3.5.1-Final
+MySql database/Drivers

> Prefix is missed in HQL query for property mapped to column 'TO_DATE' on Oracle 10g
> -----------------------------------------------------------------------------------
>
>                 Key: HHH-5135
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5135
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.0-Final, 3.5.1
>         Environment: Hibernate 3.5.1, Oracle 10.2.0.1.0
>            Reporter: Vladimir Ivanov
>         Attachments: test_case.zip
>
>   Original Estimate: 8h
>  Remaining Estimate: 8h
>
> I have entity 'Period' with property 'toDate' mapped to database column with name 'TO_DATE' (Our database is Oracle 10g). When this entity is queried via HQL, prefix for this entity is missed. Following SQL query is produced:
> Hibernate: 
>     /* 
> from
>     Period p */ select
>         * 
>     from
>         ( select
>             period0_.ID as ID44_,
>             period0_.TXN_VER as TXN3_44_,
>             period0_.FROM_DATE as FROM4_44_,
>             TO_DATE as TO5_44_,
>             period0_.POSITION_MONTH as POSITION7_44_,
>             period0_.IS_CLOSE as IS12_44_,
>             period0_.IS_OPEN as IS13_44_,
>             period0_.DISC_TYPE as DISC2_44_ 
>         from
>             SOME_SCHEMA.T_PERIOD period0_ ) 
>     where
>         rownum <= ?
> This leads to database error in case of more advanced query (with joins etc). For example, we have following error in production: java.sql.SQLException: ORA-00918: column ambiguously defined
> Probably the reason of this behaviour is that Hibernate tries to interpret 'TO_DATE' as the name of SQL function.
> In Hibernate 3.3.2.GA prefix is added correctly.
> Domain object, DAO, Test and Hibernate configuration are in the attachment.
> I used Spring framework to configure test.

-- 
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