-->
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.  [ 4 posts ] 
Author Message
 Post subject: Mapping subclass with same name but in different package
PostPosted: Wed Jun 15, 2005 12:23 pm 
Regular
Regular

Joined: Sun Nov 07, 2004 3:39 pm
Posts: 77
Is there a way of mapping the following? Let's say there's a class called 'regular.businessobjects.Product', which contains all the basic functionality for a Product to take from project to project. Now for a specific project, I want to override this class with a class of the same name in the project-specific package - so it would be 'myproject.businessobjects.Product'.

Every attempt at doing this has resulted in a message like the following:

2005-06-15 17:12:45,729 ERROR [net.sf.hibernate.cfg.Configuration] - Could not compile the mapping document
net.sf.hibernate.MappingException: duplicate import: Product

Is it not possible to map a subclass with the same name, but in a different package?

This is with Hibernate 2.1.8.


Top
 Profile  
 
 Post subject: Re: Mapping subclass with same name but in different package
PostPosted: Wed Jun 15, 2005 12:34 pm 
Regular
Regular

Joined: Sun Nov 07, 2004 3:39 pm
Posts: 77
I should point out that this is using the table-per-class-hierarchy mapping strategy. Not tried joined-subclass.


Top
 Profile  
 
 Post subject: Re: Mapping subclass with same name but in different package
PostPosted: Wed Jun 15, 2005 2:42 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
J2R wrote:
I should point out that this is using the table-per-class-hierarchy mapping strategy. Not tried joined-subclass.


look at the docs for auto-import. By default, hibernate sets this to true and allows you to use short (Class-only) names throughout. However, in your case, since this would cause the duplicate situation, you need to set this to false.

<hibernate-mapping auto-import="false">
...


Top
 Profile  
 
 Post subject: Re: Mapping subclass with same name but in different package
PostPosted: Wed Jun 22, 2005 8:58 am 
Regular
Regular

Joined: Sun Nov 07, 2004 3:39 pm
Posts: 77
pksiv wrote:
J2R wrote:
I should point out that this is using the table-per-class-hierarchy mapping strategy. Not tried joined-subclass.


look at the docs for auto-import. By default, hibernate sets this to true and allows you to use short (Class-only) names throughout. However, in your case, since this would cause the duplicate situation, you need to set this to false.

<hibernate-mapping auto-import="false">
...


Thanks, looks like I've got this working now.


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