-->
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 same class several times with different entity names
PostPosted: Wed Feb 04, 2009 6:25 am 
Newbie

Joined: Mon May 19, 2008 7:45 am
Posts: 4
Hi,

is it possible to map a class several times with different entity names using annotations?
In my case I have a second table holding the archived version of an entity.

Using XML-mapping files this would look like this:

<hibernate-mapping package="myPackage">
<class name="MyEntity" entity-name="MyEntity" table="MY_ENTITY">
<id name="id"/>
<property name="text"/>
<property name="version"/>
</class>

<class name="MyEntity" entity-name="MyEntityArchive" table="MY_ENTITY_ARCHIVE">
<id name="id"/>
<property name="text"/>
</class>
</hibernate-mapping>

Please note that there is an additional property "version" in one of the mappings. This works fine for me when using XML-mappings. How can I achieve this using annotations?

Thank you in advance,
Thilo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2009 6:40 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I am not an annotations expert, but as far as I know you need to use XML files if you want to map a class multiple times.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2009 7:25 am 
Newbie

Joined: Mon May 19, 2008 7:45 am
Posts: 4
Can I mix annotations and XML-mapping files?
The reason is I want to use hibernate-search. And this ist only possible using annotations...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2009 7:50 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Yes, you can mix it. Be sure to write metadata-complete="false", so that annotations are also read.

_________________
-----------------
Need advanced help? http://www.viada.eu


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.