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: Problem with createSQLQuery and composite primary keys
PostPosted: Mon Dec 06, 2004 11:43 am 
Newbie

Joined: Fri Dec 03, 2004 4:41 pm
Posts: 15
I'm using a create SQL query that maps to a class with composite primary keys mapping to a oracle 9i database. I need it to call a max function on a particular column that's one of the composite ids.

I keep getting the error net.sf.hibernate.QueryException: No column name found for property [partyId] though my find functions work great and it doesn't give a error on the regular property elements. Is there a way to map to composite ids using this call or a fix?

ex:
createSQLQuery("select {pad}.test as {pad.test}, max({pad}.prty_id) as {pad.partyId} " +
"from MYTABLE {pad}",
"pad", MyClass.class)

w/ or w/o the max function causes the same error


Hibernate version:
2.1.7c

Mapping documents:

<class name="MyClass" table="MYTABLE">

<composite-id name="pk" class="MyPrimaryKey">
<key-property name="partyId" column="PRTY_ID" type="java.math.BigDecimal" />
</composite-id>
<property name="test" column="modified_by" />
</class>


exception that occurs:
net.sf.hibernate.QueryException: No column name found for property [partyId]
Name and version of the database you are using:
Oracle 9i


Top
 Profile  
 
 Post subject: I had a similar post, but found the solution
PostPosted: Mon Dec 06, 2004 1:00 pm 
Newbie

Joined: Mon Dec 06, 2004 5:51 am
Posts: 8
Location: Istanbul/Turkiye
Hi,

I think your composite-id is not right. It should be something like this:

<class name="User" table="USER">
<composite-id name="userId" class="UserId">
<key-property name="userName" column="USERNAME"/>
<key-property name="organizationId" column="ORGANIZATION_ID"/>
</composite-id>
<property ...
...
</class>

Here UserId is a seperate class. Today I posted a question similar to this. But I found the solution by myself. You can see it here:

http://forum.hibernate.org/viewtopic.php?t=936801

_________________
thanks


Top
 Profile  
 
 Post subject: Thanks, big help!
PostPosted: Mon Dec 06, 2004 2:21 pm 
Newbie

Joined: Fri Dec 03, 2004 4:41 pm
Posts: 15
That worked! I had already built a quick jdbc hit to handle it but this gives me some better insight into the mechanisms of composite id handling and reduces the code by half.

I'm hoping 3.0 has some better primary key handling such as mapping to the same object for multiple primary keys.


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.