Hibernate version:2.0
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:mySQL
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
suppose I have two tables, A and B. A is the parent and B is the child with one-to-many relationship from A to B. I want to get all the data like this:
select * from A, B
where A.key1 = B.key1 -- key joins
and A.field1 = 'abc'
and B.field1='xyz'
I know a few ways to do it:
1. filter by A first then loop through B's collection to get all the matches. I don't think it is a good way
2. write the join in Java code like this:
session.find(" select a from A as a join B as b where ...")
Is there a better way to do it? How can we extract the SQL out from Java code to some XML files? Thanks,
|