-->
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.  [ 2 posts ] 
Author Message
 Post subject: Classes with the same name under different packages
PostPosted: Wed Aug 04, 2004 6:29 pm 
Newbie

Joined: Mon Jun 14, 2004 5:16 pm
Posts: 16
Location: New York
I have two classes with the same name in two different packages:

Code:
com.company.product.news.User.java
and
com.company.product.cinema.User.java


and in the hibernate configuration file I have:
Code:
<hibernate-configuration>

        <!-- Mapping files -->
        <mapping resource="com/company/product/news/User.hbm.xml"/>
        <mapping resource="com/company/product/cinema/User.hbm.xml"/>


Hibernate fails to initialize with this, complaining about duplicate
Code:
User
:

net.sf.hibernate.MappingException: duplicate import: User
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)


I am using Hibernate version 2.

In mapping files, I have the
Code:
class
attributes set to correct package names.

Is there a way around this?

Thanks,
Cagan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 6:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
In one of the mappings, turn auto-import off.
Code:
<hibernate-mapping auto-import="false" ...>
    <class.../>
</hibernate-mapping>


Note that you will then need to refer to the fully qualified class name in HQL for the class in the maping where you disabled auto-import (or use an explicit import).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.