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
|