-->
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: Criteria queries problems using sub-class attributes
PostPosted: Tue Mar 11, 2008 8:24 am 
Newbie

Joined: Fri Sep 21, 2007 11:54 am
Posts: 9
Location: Switzerland
Dear all,

I'm having a strange behaviour using Hibernate Criteria API on entities sub-classes. Here is the testing I did:

I have the following entities:
- class User with attribute "name", "surname"
- class SpecificUser which is a sub-class of User class with "addresses" attribute which is mapped as a one-to-many Set (addresses Set<UserAddress>).
- Class UserAddress which contains attributes like street, etc.

Using Criteria API, I'm getting the following exception when I'm trying to query a one-to-many attribute on the sub-class:

Quote:
ERROR: table name "user1_" specified more than once


Here is the query:

Code:
Criteria criteria =  session.createCriteria(User.class);     
criteria.createCriteria("addresses").add(Restrictions.like("street", "Long Street%"));


This query only work when the first Criteria is defined as follow:
Code:
Criteria criteria =  session.createCriteria(SpecificUser.class);

Looking to the SQL, it seems hibernate is doing the same join twice...

My inheritance mapping is done using "Table per class hierarchy" and I get no problem doing queries on other polymorphic associations...

Any hint is welcome !

Thanks in advance,

Joël


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.