-->
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.  [ 1 post ] 
Author Message
 Post subject: load or get not working with composite PK
PostPosted: Tue Jul 19, 2005 10:28 am 
Newbie

Joined: Wed Apr 06, 2005 1:13 pm
Posts: 13
Hi all,

I´m using Hibernate 3 with an Firebird database.

My problem is that I have an table with an composite PK and the get or load method in hibernate session is not working, debugging i see that the sql query generated is wrong, its include the name of the pk field in the query.

Here is my class and the PK class, I ommited the irrelevant fields and relashionships :

@Entity (access = AccessType.PROPERTY)
@Table (name = "RESOURCE_GROUP")
public class Resource_GroupVO extends BaseVO {

....

@EmbeddedId
public Resource_GroupKeyVO getPk() {
return pk;
}


..... }

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

public class Resource_GroupKeyVO extends BaseVO {

.....

@Column (name = "id_resource", nullable = false)
public Integer getId_resource() {
return id_resource;
}

@Column (name = "id_group", nullable = false)
public Integer getId_group() {
return id_group;
}

}


Well, when i call the load or the get method in the hibernate session I get the following exception :

[2005-07-19 11:18:36,578] main org.hibernate.event.def.DefaultLoadEventListener INFO - Error performing load command
org.hibernate.exception.GenericJDBCException: could not load an entity: [br.com.venus.model.valueobjects.Resource_UserVO#component[id_resource,id_user]{id_user=1, id_resource=1}]

Bellow is the Hibernate SQL Output, look that the problem is that Hibernate is generating the query with PK before the column that is part of the key.
Ex.: resource_u0_.pk.id_resource as pk4_8_5_

Hibernate: select resource_u0_.id_resource as id1_5_, resource_u0_.id_user as id2_5_, resource_u0_.pk.id_resource as pk4_8_5_, resource_u0_.creation_timestamp as creation3_8_5_, resource_u0_.pk.id_user as pk5_8_5_, resourcevo1_.id_resource as id1_0_, resourcevo1_.id_resource_parent as id4_11_0_, resourcevo1_.id_resource_type as id2_11_0_, resourcevo1_.creation_timestamp as creation3_11_0_, resourcevo1_.last_change_timestamp as last5_11_0_, resourcevo1_.name_resource as name6_11_0_, resourcevo1_.text_key as text7_11_0_, resourcevo1_.action_jsf as action8_11_0_, resourcevo1_.icon as icon11_0_, resourcevo1_.label as label11_0_, resourcevo1_.split as split11_0_, resourcevo1_.show_order as show12_11_0_, resourcevo2_.id_resource as id1_1_, resourcevo2_.id_resource_parent as id4_11_1_, resourcevo2_.id_resource_type as id2_11_1_, resourcevo2_.creation_timestamp as creation3_11_1_, resourcevo2_.last_change_timestamp as last5_11_1_, resourcevo2_.name_resource as name6_11_1_, resourcevo2_.text_key as text7_11_1_, resourcevo2_.action_jsf as action8_11_1_, resourcevo2_.icon as icon11_1_, resourcevo2_.label as label11_1_, resourcevo2_.split as split11_1_, resourcevo2_.show_order as show12_11_1_, resource_t3_.id_resource_type as id1_2_, resource_t3_.description as descript2_12_2_, resource_t3_.creation_timestamp as creation3_12_2_, resource_t3_.last_change_timestamp as last4_12_2_, uservo4_.id_user as id1_3_, uservo4_.login as login13_3_, uservo4_.creation_timestamp as creation3_13_3_, uservo4_.last_change_timestamp as last4_13_3_, uservo4_.email as email13_3_, uservo4_.passwd as passwd13_3_, groups5_.ID_USER as ID1_7_, groupvo6_.id_group as ID2_7_, groupvo6_.id_group as id1_4_, groupvo6_.description as descript2_9_4_, groupvo6_.creation_timestamp as creation3_9_4_, groupvo6_.last_change_timestamp as last4_9_4_ from RESOURCE_USER resource_u0_ left outer join RESOURCES resourcevo1_ on resource_u0_.pk.id_resource=resourcevo1_.id_resource left outer join RESOURCES resourcevo2_ on resourcevo1_.id_resource_parent=resourcevo2_.id_resource left outer join RESOURCE_TYPES resource_t3_ on resourcevo2_.id_resource_type=resource_t3_.id_resource_type left outer join USERS uservo4_ on resource_u0_.pk.id_user=uservo4_.id_user left outer join USER_GROUP groups5_ on uservo4_.id_user=groups5_.ID_USER left outer join GROUPS groupvo6_ on groups5_.ID_GROUP=groupvo6_.id_group where resource_u0_.id_resource=? and resource_u0_.id_user=?


Thanks in advance
Rogerio


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

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.