Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate mapping.

 
Punya Pratap Singh
Ranch Hand
Posts: 81
  • 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
1-CUSIP
2-LIPPER_CAT(id)

table 2 - fields

1-LIPPER_CAT
2-UBS_CAT_CD(id)

table 3 - fields
1-UBS_CAT_CD
2-UBS_CAT_DS
3-UBS_SEQ
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();
session.close();

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">
<list>
<value>
com/hewitt/websolutions/emp/persistence/hibernate/LipperAstCat.hbm.xml
</value>
</list>
</property>

In the same xml file I have mapping like this

<bean id="LipperAstCatDAO"
class="com.hewitt.websolutions.emp.persistence.hibernate.dao.LipperAstCatDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

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