-->
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.  [ 4 posts ] 
Author Message
 Post subject: Getting one-to-many childs as part of resultset in query
PostPosted: Tue Jul 12, 2005 3:20 pm 
Beginner
Beginner

Joined: Mon Mar 28, 2005 12:58 pm
Posts: 27
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: annotations beta 3 and hibernate 3.0.5

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

My dream solution of using @Transient methods to simplify my problem didn't work out too well so I thought I'd pose the question to my fellow hibernaters. I've got a parent and child table with a one-to-many relationship. Example:
Parent
Code:
public class Person
{

    @OneToMany
    public List<PersonNumbers> getPersonNumbers()
    {
        ...
    }
}

Child
Code:
public class PersonNumbers
{
    private String number;
    private String name;  // describes the number type (ssn, driver's license, etc)

    @ManyToOne
    public Person getPerson()
    {
        ....
    }
}

Essentially I'm using the PersonNumbers table to keep track of a person's IDs such as driver's license and SSN. When I query for the person I want to be able to return the child table entries as columns in the resulting rows. (e.g. last name, first name, ssn, drivers license, birthdate). I had @Transient methods in the Person class to explicitly get these values but can't use them as properties in HQL. So now I'm completely clueless as to how to accomplish this. All sorts of wild ideas are welcome at this point!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 1:58 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
<join> and a where clause on the name should solve the problem.

<join> => @SecondaryTable
for the where clause on a @SecondaryTable I don't think I've impelmented that yet.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 6:04 pm 
Beginner
Beginner

Joined: Mon Mar 28, 2005 12:58 pm
Posts: 27
Do you know when the "where" clause support will go into annotations? This would solve one of my showstoppers. Even pointing me to where I could look up some of the code to tinker around would help. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 5:06 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't have any timeframe, I'm focussed on bugfixing and EJB3 compliance for now.

Hum, this part in not very clean/separated, it's in AnnotationBinder.bindClass()

_________________
Emmanuel


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