-->
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: Multiple mappings for same class
PostPosted: Sat Feb 14, 2004 4:41 pm 
Beginner
Beginner

Joined: Thu Oct 23, 2003 1:43 pm
Posts: 23
Hi,


Is there any way to specify so that I can use different mappings for the same class. We have couple of mapping files, one contains the whole heirachy with collection of sets and the other one is just flat. Based on different scenario, can i specify one mapping file over the other.


In the below 2 mappings, Mapping 1 internally maps to a set whereas Mapping 2 is not. But these 2 mappings is for the same class.

Mapping 1:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.win.core.bo.cardio.CardioWorkout" table="CARDIO_WORKOUT">
<!--<jcs-cache usage="read-write"/>-->
<id name="id" column="WORKOUT_NR" type="long">
<generator class="sequence">
<param name="sequence">CARDIO_WORKOUT_SEQ</param>
</generator>
</id>
<property name="parentId" column="PERSON_NR" type="long"/>
<property name="date" column="WORKOUT_DATE" type="date"/>

<set name="activitySet" table="CARDIO_ACTIVITY" lazy="false" cascade="all" inverse="true"
where="IS_DELETED='N'"
order-by= "activity_nr asc">
<!--<jcs-cache usage="read-write"/>-->
<key column="WORKOUT_NR"/> <one-to-many class="com.win.core.bo.cardio.CardioActivity"/>
</set>
</class>
</hibernate-mapping>


Mapping2:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.win.core.bo.cardio.CardioWorkout" table="CARDIO_WORKOUT">

<id name="id" column="WORKOUT_NR" type="long">
<generator class="sequence">
<param name="sequence">CARDIO_WORKOUT_SEQ</param>
</generator>
</id>
<property name="parentId" column="PERSON_NR" type="long"/>
<property name="date" column="WORKOUT_DATE" type="date"/>
</class>
</hibernate-mapping>


Best Regards,
raghu


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 14, 2004 6:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can create multiple SessionFactorys with different mappings.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 14, 2004 6:28 pm 
Beginner
Beginner

Joined: Thu Oct 23, 2003 1:43 pm
Posts: 23
Thank you very much. I will try to do that.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 14, 2004 10:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate 2.2 will support this (actually v22branch already does), via the notion of "named entities".


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.