当前位置: 动力学知识库 > 问答 > 编程问答 >

Hibernate Mapping Question

问题描述:

i am trying to map some classes using some hibernate and arrived at a case where i am unable to find the best way to achieve the solution.

i have three classes namely AirTransport,TrainTransport and RoadTransport and they have certain properties which are getting mapped correctly.

we have to store TRANSPORTTIME entries of these classes but don't want to store time entries of individual classes in there respective tables,

we want to create a TRANSPORTTIME table where we can store time related entries of the above defined three classes.

since these three classes are independent so i am confused how best to map these classes's time entry in to the TRANSPORTTIME table.

i tried to do something like this in the three transport classes

<set name="timeTable" table="TRANSPORTTIME" inverse="true" lazy="true">

<key>

<column name="UUID" />

</key>

<one-to-many class="TransportTime" />

</set>

but not sure how to map the things on the other side i.e TRANSPORT table

any help or pointer in this regard will be helpfull

网友答案:

If you are sure UUID does not have the same value across different Transport, it could work. But I would prefer to use a map instead of a set avoiding to have TransportTime as an entity, but just as a value.

分享给朋友:
您可能感兴趣的文章:
随机阅读: