-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: mapping one pojo with multiple tables
PostPosted: Tue Sep 13, 2011 5:14 am 
Newbie

Joined: Tue Sep 13, 2011 5:09 am
Posts: 2
Hibernate version 3.2

i have 3 tables and a single pojo is mapped with three in hbm.file with entity-name defined as ::

<class name="com.hr.dto.CandidateRecruitmentDTO" table="TB_SOFT_INTRV_DETAILS" entity-name="softwareObject">

<class name="com.hr.dto.CandidateRecruitmentDTO" table="TB_SOFT_INTRV_DETAILS" entity-name="bpoObject">

<class name="com.hr.dto.CandidateRecruitmentDTO" table="TB_SOFT_INTRV_DETAILS" entity-name="othersObject">

How to fetch data from table based on entity-name as defined in hbm.file. I am using the following qury in DAO class:
recruitmentlist = session.createSQLQuery(" FROM NewCandidateRecruitmentDTO as e").addEntity("softwareObject", NewCandidateRecruitmentDTO.class).list();

Its throwing exception ::: org.hibernate.MappingException: Unknown entity: com.ebix.hrms.dto.CandidateRecruitmentDTO
help me out.....


Top
 Profile  
 
 Post subject: Re: mapping one pojo with multiple tables
PostPosted: Tue Sep 13, 2011 7:12 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
There are several problems with your code.

First, when you are using createSQLQuery() the query string must be a valid SQL. You need SELECT ... FROM <table-name>. For example

Code:
SELECT * FROM TB_SOFT_INTRV_DETAILS


Second, when you call addEntity() you should only specify the entity-name not the class. For example:

Code:
addEntity("softwareObject")


Top
 Profile  
 
 Post subject: Re: mapping one pojo with multiple tables
PostPosted: Tue Sep 13, 2011 7:33 am 
Newbie

Joined: Tue Sep 13, 2011 5:09 am
Posts: 2
Thanks a lot :-) ... nordborg. It was helpfull.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.