数据库没设置主键,Hibernate中又不想映射数据库中的序列,该怎么办?我这样配置也有问题,求强人搭救? 30
<?xmlversion="1.0"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD...
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.boco.power.statistic.pojo">
<id >
<generator class="sequnece">
</generator>
</id>
<property name="Id" column="AREA" type="string" not-null="true" length="19" />
<property name="BsDc" column="BS_DC" type="long" not-null="false" length="19" />
<property name="BsUps" column="BS_UPS" type="long" not-null="false" length="19" />
<property name="BsAirc" column="BS_AIRC" type="long" not-null="false" length="19" />
<property name="State" column="STATE" type="long" not-null="false" length="19" />
<property name="StatTime" column="STAT_TIME" type="timestamp" not-null="false" length="11" />
</class>
</hibernate-mapping>
<class name="StatBsEquip" table="STAT_BS_EQUIP" >
刚才少粘一行,现在补上,问题同上 展开
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.boco.power.statistic.pojo">
<id >
<generator class="sequnece">
</generator>
</id>
<property name="Id" column="AREA" type="string" not-null="true" length="19" />
<property name="BsDc" column="BS_DC" type="long" not-null="false" length="19" />
<property name="BsUps" column="BS_UPS" type="long" not-null="false" length="19" />
<property name="BsAirc" column="BS_AIRC" type="long" not-null="false" length="19" />
<property name="State" column="STATE" type="long" not-null="false" length="19" />
<property name="StatTime" column="STAT_TIME" type="timestamp" not-null="false" length="11" />
</class>
</hibernate-mapping>
<class name="StatBsEquip" table="STAT_BS_EQUIP" >
刚才少粘一行,现在补上,问题同上 展开
4个回答
展开全部
你可以交给hibernate来管理你的主键,但不能没有主键!
<id >
<generator class="native">
</generator>
</id>
<id >
<generator class="native">
</generator>
</id>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
hibernate必须要求库表存在主键的。如果没有主键,建议使用复合主键,如:
<composite-id class="复合主键类" name="keyId">
<key-property name="字段名"
type="string">
<column name="字段名" not-null="true"
sql-type="nvarchar(32)" />
</key-property>
</composite-id>
<composite-id class="复合主键类" name="keyId">
<key-property name="字段名"
type="string">
<column name="字段名" not-null="true"
sql-type="nvarchar(32)" />
</key-property>
</composite-id>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-05-04
展开全部
强人数据中心是个大骗子!我深有体会!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询