-->
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.  [ 2 posts ] 
Author Message
 Post subject: Question regarding joins
PostPosted: Wed Jan 31, 2007 10:08 pm 
Newbie

Joined: Wed Jan 31, 2007 9:40 pm
Posts: 1
Location: Sydney, Australia
Hi everyone,

I've very new to using Hibernate and have been unable to find any information to help me out with this scenario.

If I have several Objects, something like...
(yes I haven't put the getters/setters in)

Code:
class Parent
{
  long aLongId
  long anotherLongId
  ListImpl getData()
}

class Child
{
  String name;
  String value;
}


* There is a one to many of between Parents and Children

I've been able to pull in Parent objects fine with all related Child objects using QBE as documented.

The problem I am having is pulling in Child objects where the Parent has say anotherLongId of 1

ie.

Quote:
SELECT "all Children objects" WHERE "the child's parent anotherLongId attribute" = 1 AND "children object's name" = 'aChildname'


In SQL I'd expect something like...

Code:
SELECT c.value
  FROM Child c
  JOIN Parent p on p.data_id = c.id
WHERE c.name = 'aChildName'
   AND p.anotherLongId = 1

Any help would be appreciated. If this is documented somewhere any pointers would be good. I've read all the hibernate.org online doco.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 2:05 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi hiberN00b,

Plz.. Look to use Criteria and Restriction. Applying restriction on Parent is quite sample. Refer Hibernate In Action

_________________
Dharmendra Pandey


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.