-->
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.  [ 1 post ] 
Author Message
 Post subject: Simple persistence of Collection not related to any entity
PostPosted: Tue Sep 23, 2008 6:05 am 
Newbie

Joined: Tue Sep 23, 2008 5:48 am
Posts: 1
Hi all,
First, I'd like to thank you all for all the good practices and solutions Ive been able to find here.

I am know facing a very simple problem and don't know which direction to take. I was not able to find anything helpful in the forum at this time.
I would like to persist a simple collection of entities in a unique DB Table.

I have two classes in my java model, Trip and TripList.
A TripList just contains a collection of Trips and an Id, and a Trip contains few properties and is identified by a name and the id of the owner list .

I would like to store it in a unique DB table with columns listID, name, props...

I came up with the following mapping.
[code]<class name="TripList" lazy="false">
<id name="tripId" type="long"/>
<list name="trips" table="Trips" lazy="false">
<key column="solutionId"/>
<index column="name"/>
<element type="Trip"/>
</list>
</class>
<class name="Trip" table="Trips" lazy="false">
<composite-id>
<key-property name="tripId" column="tripId" type="long"/>
<key-property name="name" column="name" type="string"/>
</composite-id>
<property name="start" column="start" type="double"/>
<property name="end" column="end" type="double"/>
</class>[/code]

Hibernate keep asking for a specific table to persist the TripList entity.
I understand that the proper way to go is to have a table TripList that just refrences the list of Trip IDs and then the mapping to the collection of trips is easy to do.

But I would like to avoid to create this table which is just a duplicate of data.
Does someone see a way of having hibernate map this Object structure to a single table?

Thanks a lot for your time


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.