-->
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: Questions about Hibernate Query over Collections
PostPosted: Tue Oct 10, 2006 11:12 am 
Newbie

Joined: Tue Jan 24, 2006 12:04 pm
Posts: 12
Code:
class Shop {
     Integer id;
     Set<RelContact> relContacts; //getter and setter omitted
}

class RelContact {
    Contact contact;
    RelationType relationType;
}

class Contact {
    Integer id;
    String firstname;
    String lastname;
}


here is the HQL
" from Shop s where s.relContacts.contact.firstname like'xxx' ".

any wrong with the hql above?
it can work under hibernate 3.0, but when with 3.1.3 it throws following exception.

org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: firstname of: component[contact,relationType]
[from Shop s where s.relContacts.contact.firstname='xxx' ];

any advice will be appreciated!

Code:
Code:


Last edited by kaisor on Wed Oct 11, 2006 4:17 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Need more information
PostPosted: Tue Oct 10, 2006 12:15 pm 
Beginner
Beginner

Joined: Mon Apr 24, 2006 9:47 pm
Posts: 33
Location: Kansas City, MO
Post your Hibernate mapping files for these three classes.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 11, 2006 4:14 am 
Newbie

Joined: Tue Jan 24, 2006 12:04 pm
Posts: 12
The relationship table between shop and contact ist a composite-element. It
contains three id: shopid, contactid and relationId. (contact can be assigned to shop under different relationtype)

here is the hbm
Code:
<set name="relContacts"
       table="REL_OBJ_CONTACT"
       cascade="save-update, delete"
   lazy="false">
       <key column="SHOPID"/>
         
   <composite-element class="RelContact">
      <many-to-one name="contact"
          column="contactid"
          not-found="ignore"
          class="Contact"
          cascade="save-update"/>
      
                <many-to-one name="relationType"
          column="relationid"
               not-found="ignore"
              class="RelationType"
          cascade="save-update"/>

     </composite-element>
</set>


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.