【发布时间】:2011-06-08 20:03:40
【问题描述】:
我需要在 Hibernate 中使用一些遗留类。其中一个类没有默认构造函数,因此我收到“org.hibernate.InstantiationException:实体没有默认构造函数:..”错误。我不需要直接坚持这个类。这是映射:
<class name="test.geo.support.Observation" table="observation">
<id access="property" column="obs_msg" name="EncodedObMsg" type="string"/>
<property name="ReportTime" column="report_time" type="long" />
<many-to-one name="Station" column="station_id" class="test.geo.Station"/>
</class>
<class name="test.geo.Station" table="station">
<id access="property" column="station_id" name="UniqueId" type="string" />
<component name="Point" class="test.geo.geometry.PointGeometry">
<property name="latitude" type="double" access="field" column="lat" />
<property name="longitude" type="double" access="field" column="lon" />
</component>
</class>
我需要持久化“观察”和“站”,并希望引用“PointGeometry”类来持久化 Station.Point。 'PointGeometry' 没有默认构造函数,有什么方法可以解决这个问题?
【问题讨论】:
标签: java hibernate hibernate-mapping