Hi All,
I am using Hibernate 3.0 in one of the sample application. I want to retrieve data from two tables implementing joins.I tried a lot to retrieve the desired result but it is giving wrong results. There are two tables defectdetails and lookupdetails and the respective POJOs are Defect and Lookup.The table structure in MYSQL is something like this:
Code:
lookupdetails:
Code bigint(20) (Primary key)
Category varchar(20)
Description varchar(30)
Sample data in lookupdetails table:
Code Category Description
3 priority Low
4 priority Medium
5 priority High
defectdetails:
DefectID bigint(20) Primary key
PriorityCode bigint(20)
AssignedTo varchar(50)
Summary varchar(150)
Description text
Sample data in defectdetails table:
DefectID PriorityCode AssignedTo Summary Description
1 3 Marsh HTMl issues HTML issues
2 3 David bla bla bla bla bla bla
3 5 Geoff bla bla bla bla bla bla
4 4 Marsh bla bla bla bla bla bla
Now I want to have inner join between two tables on defectdetails.PriorityCode = lookupdetails.Code.
The desired result should be something like this:
DefectID Priority AssignedTo Summary Description
1 Low Marsh HTMl issues HTML issues
2 Low David bla bla bla bla bla bla
3 High Geoff bla bla bla bla bla bla
4 Medium Marsh bla bla bla bla bla bla
Can anyone please design the entry that are suppose to be there in defect.hbm.xml and lookup.hbm.xml apart from normal property entries in order to implement this join. Also mention the hibernate query.
All suggestions are welcome.
Thanx in Advance,
Chirag.