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]