Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate mapping.

Punya Pratap Singh
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new in hibernate, I need to complete a task in which I have to pick the data from 3 tables.
table one - fields

table 2 - fields


table 3 - fields
so I will use first table ID to make join with 2nd table and 2nd table id for making join to 3rd table.
Just for example - I am using following code if I have to pick data from only one table that is -LipperAstCat
code is as follows-

LipperAstCatDAO lipperAstCatDAO = ((LipperAstCatDAO)getDAO("LipperAstCatDAO"));
String hql = "from LipperAstCat ";

Session session = lipperAstCatDAO.getSessionFactory().openSession();
Query query = session.createQuery(hql);
ArrayList<LipperAstCat> ssFundAstCat = (ArrayList<LipperAstCat>)query.list();

return ssFundAstCat;

LipperAstCat table has two files in this so I am using a bean class(with getter setters) and LipperAstCatDAO class from where I am getting session.
I have a persistence.xml file which is having
<property name="mappingResources">

In the same xml file I have mapping like this

<bean id="LipperAstCatDAO"
<property name="sessionFactory">
<ref bean="sessionFactory" />

LipperAstCat.hbm.xml has LipperAstCat table mapping.
and I am getting data comfortably.

So In join sceniro how would I do all this to get data.
Can you please help me in this ? Thanks.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic