-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: HQL does not differentiate between long id and sourceAuditId
PostPosted: Wed Dec 13, 2006 2:23 pm 
Beginner
Beginner

Joined: Tue Dec 12, 2006 6:43 am
Posts: 32
Location: London
Dear All,
I want your openion if I shall submit this as a bug into JIRA.
The problem:
I have a persistant class called SourceAudit as described below

public class SourceAudit implements Serializable {


private long sourceAuditId; PK

private Date version;

private long id; // a property


etc...

}

the mapping file name is SourceAudit.hbm.xml

<hibernate-mapping
package="....model.audit">
<class name="SourceAudit" table="SourceAudit" schema="MySchema"
catalog="myCatalog">
<id name="sourceAuditId" type="long">
<column name="sourceAuditId" precision="5" scale="0" />

<generator class="native" />

</id>

<timestamp name="version" column="version" />

<property name="id" type="long">
not-null="true" />
</property>
-->

</class>
</hibernate-mapping>


if I execute the following query
"From SourceAudit s where s.id=28"

the HQL translate it as
s.id -> sourceaudi0_.sourceAuditId

which means
s.id is s.sourceAuditId which is not true.

The log file below :


11922 DEBUG [main] jdbc.JDBCContext - after transaction begin
63655 DEBUG [main] query.QueryPlanCache - unable to locate HQL query plan in cache; generating (from SourceAudit s where s.id=28)63655 DEBUG [main] ast.QueryTranslatorImpl - parse() - HQL: from com.rbsg.groupmarketrisk.allcodes.model.audit.SourceAudit s where s.id=28
63701 DEBUG [main] tree.DotNode - getDataType() : id -> org.hibernate.type.LongType@15ad36d
63701 DEBUG [main] tree.FromReferenceNode - Resolved : s.id -> sourceaudi0_.sourceAuditId
63701 DEBUG [main] antlr.HqlSqlBaseWalker - select : finishing up [level=1, statement=select]
63701 DEBUG [main] ast.HqlSqlWalker - processQuery() : ( SELECT ( FromClause{level=1} foo.MySchema.SourceAudit sourceaudi0_ ) ( where ( = ( sourceaudi0_.sourceAuditId sourceaudi0_.sourceAuditId id ) 28 ) ) )
63701 DEBUG [main] ast.HqlSqlWalker - Derived SELECT clause created.




if I change the id into pkId it works fine.

Thanks

_________________
Alan Mehio
London
UK


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 5:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
standard behavior in hibernate until recently is that id in hql always refer to the identifier no matter if it had a name or not.

That has been relaxed in svn to support querying on properties named id

http://opensource.atlassian.com/project ... e/HHH-1851

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: This makes sense to me
PostPosted: Thu Dec 14, 2006 7:53 am 
Beginner
Beginner

Joined: Tue Dec 12, 2006 6:43 am
Posts: 32
Location: London
max wrote:
standard behavior in hibernate until recently is that id in hql always refer to the identifier no matter if it had a name or not.

That has been relaxed in svn to support querying on properties named id

http://opensource.atlassian.com/project ... e/HHH-1851



Thanks Max
I read the comments from the given link.
This makes sense.

_________________
Alan Mehio
London
UK


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.