hibernate 主键
我有一张表
映射了两个类
现在怎么设主键啊?
我想讲主键设为自动增长
------解决方案--------------------
------解决方案--------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.willfar.commons.archive.entity.ObjectStructData" table="OBJECT_STRUCT_DATA">
<composite-id name="id" class="com.willfar.commons.archive.entity.ObjectStructDataId">
<key-property name="objectStructId" type="java.lang.Integer">
<column name="OBJECT_STRUCT_ID" length="10" />
</key-property>
<key-property name="objectId" type="java.lang.Long">
<column name="OBJECT_ID" length="10" />
</key-property>
</composite-id>
<property name="objectStructValue" type="java.lang.String" column="OBJECT_STRUCT_VALUE" not-null="false" length="128" />
<property name="objectStructInfo" type="java.lang.String" column="OBJECT_STRUCT_INFO" not-null="false" length="128" />
</class>
</hibernate-mapping>
ObjectStructData实体
ObjectStructDataId ID
------解决方案--------------------
在配置中用<generation class=native>就Ok了,
------解决方案--------------------
------解决方案--------------------
只有基础类型的数据才能映射为主键