The moose likes Object Relational Mapping and the fly likes Hibernate mapping. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate mapping." Watch "Hibernate mapping." New topic

Hibernate mapping.

Punya Pratap Singh
Ranch Hand

Joined: Nov 23, 2010
Posts: 81
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.
I agree. Here's the link:
subject: Hibernate mapping.
It's not a secret anymore!