Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Hibernate HSQL syntax for Associations

Thread view: 
wls - 03 Oct 2007 19:10 GMT
I've got a one-to-many association between two entities, X and Y.

class X {
   @OneToMany( cascade = CascadeType.ALL )
   private List<Y> collection = new ArrayList<Y>();
}

What's the HSQL notation to return any X who's collection contains a Y
with a specific property?

In SQL, I'd do a join between X and Y where Y.whatever = value.
However, I think I'm using the wrong terminology, as I can't seem to
find an example in the Hibernate Reference Documentation (version
3.2.5).

So, I backed off and tried just finding if a thing was in a
collection, using:

 List<X> found = session.createQuery(  "from X x where :y in
( x.collection )"  ).setEntity( "y", y ).list();

Naturally this gives me syntax error.

Can anyone point me in the right direction?

Thanks in advance,
-Walt Stoneburner, wls@wwco.com
http://www.wwco.com/~wls/
rico.fabrini@gmail.com - 04 Oct 2007 03:19 GMT
> I've got a one-to-many association between two entities, X and Y.
>
[quoted text clipped - 6 lines]
> What's the HSQL notation to return any X who's collection contains a Y
> with a specific property?

It's called HQL (not HSQL)

I would suggest:
"from X as x join x.collection as y where y.something = :something1"

Rico.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.