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.  [ 8 posts ] 
Author Message
 Post subject: why is hibernate adding "id" in the query?
PostPosted: Fri Oct 01, 2004 3:35 pm 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
why is hibernating substituting primary key projectReleasePK with "id"?
----------------------------------------------------------------------------------
DEBUG [15:26:19,023] [] [net.sf.hibernate.impl.SessionImpl:1328] - find: from prjtsk in class ProjectReleaseTaskSubTask where prjtsk.projectReleaseTaskSubTaskPK.projectRelease.projectReleasePK.project.prjCode = '1130'
DEBUG [15:26:19,083] [] [net.sf.hibernate.hql.QueryTranslator:144] - compiling query
net.sf.hibernate.QueryException: could not resolve property type: projectReleaseTaskSubTaskPK.projectRelease.id.project.id [from prjtsk in class ProjectReleaseTaskSubTask where prjtsk.projectReleaseTaskSubTaskPK.projectRelease.projectReleasePK.project.prjCode = '1130']

net.sf.hibernate.QueryException: could not resolve property type: projectReleaseTaskSubTaskPK.projectRelease.id.project.id [from prjtsk in class ProjectReleaseTaskSubTask where prjtsk.projectReleaseTaskSubTaskPK.projectRelease.projectReleasePK.project.prjCode = '1130']
at net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpressionParser.java:235)
at net.sf.hibernate.hql.PathExpressionParser.end(PathExpressionParser.java:281)
at net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:366)
at net.sf.hibernate.hql.WhereParser.doToken(WhereParser.java:393)
at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:279)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:120)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:146)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:133)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:352)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:330)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1368)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1332)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1314)


Top
 Profile  
 
 Post subject: is there a limit in the query class?
PostPosted: Fri Oct 01, 2004 4:12 pm 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
Looks like hibernate doesn't like long names and replaces randomly the primary key class names with "id".
Is there a limit defined somewhere to the length of the query name?


Top
 Profile  
 
 Post subject: strange
PostPosted: Fri Oct 01, 2004 4:48 pm 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
Now this is strange. When i change the query to clip off project.prjCode and use only till prjtsk.projectReleaseTaskSubTaskPK.projectRelease.projectReleasePK and fetch for one of its attributes like
prjtsk.projectReleaseTaskSubTaskPK.projectRelease.projectReleasePK.title,
it works fine but as soon as project.prjCode is added, it starts to substitute the **PK's with id's.

Any suggestions?
I've tried shortenening the names of my classes as well still the same.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 02, 2004 1:42 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
I guess this is a mapping bug.
If you post a minimzed example with the information asked by the red box, maybe someone can spot the problem. Often I find bugs while preparing this information for a problem!

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 02, 2004 10:58 am 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
The mapping is fine as you can see from the "from" clause. Its only when its compiling the query, hibernate is somehow replacing the primary key attributes with just "id".

With the same mapping if i just query the "Project" table and traverse through release and task sub task classes, everything is fine. Its doing this only when i try to query from the task sub task table that has a matching prjoect code.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 02, 2004 1:22 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It looks like a wrong query, you have provided no information, but it looks like you want to select this :
from prjtsk in class ProjectReleaseTaskSubTask where prjtsk.projectRelease.project.prjCode = '1130'


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 10:31 am 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
Here are the mappings :
--------------------------------------------------

<class
name="Project"
table="PRJ"
>

<id
name="prjCode"
type="java.lang.String"
column="PRJ_Code"
>
<generator class="assigned" />
</id>

............

<set
name="projectReleases"
lazy="true"
inverse="true"
>
<key>
<column name="PRJ_Code" />
</key>
<one-to-many
class="ProjectRelease"
/>
</set>

--------------------------------------------------------------------------



<class
name="ProjectRelease"
table="REL"
>

<composite-id name="projectReleasePK" class="ProjectReleasePK">
<key-property
name="prlseNum"
column="PRLSE_NUM"
type="java.lang.String"
length="4"
/>

<key-many-to-one
name="project"
class="Project"
>
<column name="PRJ_CD" />
</key-many-to-one>
</composite-id>

......................................

<set
name="projectRelTaskSubTasks"
lazy="true"
inverse="true"
>
<key>
<column name="PRJ_CD" />
<column name="PRLSE_NUM" />
</key>
<one-to-many
class="ProjectRelTaskSubTask"
/>
</set>


---------------------------------------------------------------------------------

<class
name="ProjectReleaseTaskSubTask"
table="RTS"
>

<composite-id name="projectReleaseTaskSubTaskPK" class="ProjectReleaseTaskSubTaskPK">
<key-property
name="prlseTaskCode"
column="PRLSE_TASK_CD"
type="java.lang.String"
length="4"
/>
<key-property
name="prlseStskCode"
column="PRLSE_STSK_CD"
type="java.lang.String"
length="2"
/>

<key-many-to-one
name="projectRelease"
class="ProjectRelease"
>
<column name="PRJ_CD" />
<column name="PRLSE_NUM" />
</key-many-to-one>
</composite-id>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 12:48 pm 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
Has anyone come across this problem? Where you have three table related with composite primary keys?
Does anyone see any problem with the mapping or the query?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.