-->
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: join request one to many
PostPosted: Mon Jan 11, 2010 11:15 am 
Newbie

Joined: Mon Jan 11, 2010 11:05 am
Posts: 8
i have two objects with one to many relation between, like Person and vehicule.
and a set of vehicules is an attribut of Person Object like that :
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name="fk_peson")
private Set<Vehicule> cars;

so how to implements the method getVehiculesForPerson(personId)??
something like this, i know it's not correct :
getHibernateTemplate().find("from Vehicule as v join Person as p where p.personId=?",new Object[] { personId});

thanks


Top
 Profile  
 
 Post subject: Re: join request one to many
PostPosted: Mon Jan 11, 2010 12:51 pm 
Newbie

Joined: Sat Jan 09, 2010 3:23 pm
Posts: 5
Code:
session.CreateCriteria(Vehicule)
                           .CreateAlias("Person", "P")
                           .Add(Expression.Eq("P.Id", personId))
                           .List();


Cheers,
Andre


Top
 Profile  
 
 Post subject: Re: join request one to many
PostPosted: Thu Jan 14, 2010 10:32 am 
Newbie

Joined: Mon Jan 11, 2010 11:05 am
Posts: 8
thanks,

i'am getting this error :

org.hibernate.QueryException: could not resolve property: Person of: mypackage.Vehicule

any idea???

p.s. i think i don't use the good session! i'have somthing like
session.createCriteria(Vehicule.class).add(Expression.eq


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.