-->
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: Query enhancement question...
PostPosted: Tue Jun 26, 2007 6:07 am 
Newbie

Joined: Mon Jun 25, 2007 3:06 pm
Posts: 5
Hibernate version:3.0

Hi group,

actually I working aroung the following problem. I have a Spring/Hibernate/MySQL scenario with 2 entity classes each mapped to an mysql table.

So my (reduced) coding looks like:

Code:
@Entity
@Table(name = "books")
public class Book {

[...]
        @OneToMany(cascade = CascadeType.ALL)
   @JoinColumn(name = "chapter_fk")
   public List<Chapter> getChapters() {
      return chapters;
   }

}



Of course the Chapter class has the @entity-definition as well.

So far everything works fine! If I do my DAO call with the following line
Code:
List<Books> threadList = getHibernateTemplate().find("from Book");

I get a perfect result.

This call above gets me all books with all chapters.
I know how to enhance the query to get a certain selection of books by just adding a WHERE clause to the query.

But is there a way to enhance this query to not only narrow the statement for certain books but also for certain chapters. E.g. I want all books, but the inside 'one-to-many Chapter mapping' should only return Chaperts with id=1 as an example.

Does anyone know how to solve this?

Thanks in advance
John[/i]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 04, 2007 4:22 am 
Newbie

Joined: Mon Jun 25, 2007 3:06 pm
Posts: 5
Hi,

I am just wondering, if this is a question too silly as there is no reaction up to today.

I am still looking for some hints how such a question could be solved in a Hibernate based environment.

TIA
John


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.