-->
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: POJO having same name in different packages
PostPosted: Fri Mar 02, 2007 12:40 am 
Newbie

Joined: Tue Jan 02, 2007 4:52 am
Posts: 1
I have two POJO classes, say com.samples.savings.Account.java and com.samples.current.Account.java in different packages. I have the corresponding mapping files namely savings/Account.hbm.xml and current/Account.hbm.xml. Both the POJO are mapped to separate tables in the DB namely savings_account and current_account respectively. The mappings are also provided in the hibernate.cfg.xml file as follows.

<mapping resource="savings/Account.hbm.xml"/>
<mapping resource="current/Account.hbm.xml"/>

When i execute the query to fetch records from account tables i am getting the following exception.

net.sf.hibernate.MappingException: Error reading resource: current/Account.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:340)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1027)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:983)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at com.orange.cm.test.TestHibernate.main(TestHibernate.java:14)
Caused by: net.sf.hibernate.MappingException: duplicate import: Account
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:253)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:289)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:337)

Please let me know how to resolve this issue.
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 2:44 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi binds,

Try with different name of HBM (not sure) and check that you have used class with full package path.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 4:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
All covered in the documentation.

Code:
<hibernate-mapping auto-import="false">
    <class name="savings.Account" .../>
    <class name="current.Account" .../>
</hibernate-mapping/>


Note that you would then no longer be able to use the unqualified names in HQL...


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.