请教下<hibernate-mapping>
<class name="com.song.shopping.entity.User" table="SHOPPING_SONG_USER" schema="OPENLAB">
<id name="userId" type="long">
<column name="USER_ID" precision="22" scale="0" />
<generator class="hilo" />
</id>
<property name="username" type="string">
<column name="USERNAME" length="32" not-null="true" unique="true" />
</property>
<property name="userpwd" type="string">
<column name="USERPWD" length="32" not-null="true" />
</property>
<property name="useremail" type="string">
<column name="USEREMAIL" length="64" not-null="true" />
</property>
<property name="telphone" type="string">
<column name="TELPHONE" length="20" />
</property>
<set name="shoppingSongOrders" inverse="true">
<key>
<column name="USER_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="com.song.shopping.entity.Order" />
</set>
</class>
</hibernate-mapping>
<id name="userId" type="long">
<column name="USER_ID" precision="22" scale="0" />
<generator class="hilo" />
</id>
上面的配置文件中 主键必须有序列吗?有没有没有序列的时候,没有序列的情况下如何写配置文件?
<class name="com.song.shopping.entity.User" table="SHOPPING_SONG_USER" schema="OPENLAB">
<id name="userId" type="long">
<column name="USER_ID" precision="22" scale="0" />
<generator class="hilo" />
</id>
<property name="username" type="string">
<column name="USERNAME" length="32" not-null="true" unique="true" />
</property>
<property name="userpwd" type="string">
<column name="USERPWD" length="32" not-null="true" />
</property>
<property name="useremail" type="string">
<column name="USEREMAIL" length="64" not-null="true" />
</property>
<property name="telphone" type="string">
<column name="TELPHONE" length="20" />
</property>
<set name="shoppingSongOrders" inverse="true">
<key>
<column name="USER_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="com.song.shopping.entity.Order" />
</set>
</class>
</hibernate-mapping>
<id name="userId" type="long">
<column name="USER_ID" precision="22" scale="0" />
<generator class="hilo" />
</id>
上面的配置文件中 主键必须有序列吗?有没有没有序列的时候,没有序列的情况下如何写配置文件?
解决方案 »
- 如何用tomcat在sever.xml下发布文件啊。
- 日志文件记录的错误 5条 求解
- javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
- 请教一个简单的正则表达式!急
- 高分跪求:看看这个问题!在线等!
- 一个简单的问题(simple),高分!
- 添加背景音乐问题
- JSP页面连接不上MySQL数据库,出现404错误
- 谁能弄到24日去成都的火车票????????????????????
- spring3+hibernate4+ehcache,使用原生sql查询后得到的缓存,从缓存查询数据报错
- swing界面开发有布局管理器,不知道在web开发里有没有类似的技术?
- servlet传参数
如果想自增 ,oracle里面有sequence来实现<generator class="sequence">
<param name="sequence">自己创建的sequence</param>
</generator>
这样就不需要你去关心主建,程序会自己从sequence里面去取得
<column name="USER_ID" precision="22" scale="0" />
<generator class="native" />
</id>
native 就是不使用序列?是这个意思吧?
hibernate的ID是必须的,identity可以配置标识字段...具体的要自己去找了
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" ><hibernate-mapping package="com.ruining.pojo">
<class
name="DictItem"
table="DICT_ITEM"
>
<id name="dictid" type="string" column="DICTID">
<generator class="sequence">
<param name="sequence">SEQ_DICTITEM</param>
</generator>
</id>
<property
name="groupid"
column="GROUPID"
type="string"
not-null="false"
length="64"
/>
<property
name="dictname"
column="DICTNAME"
type="string"
not-null="false"
length="64"
/>
<property
name="shortname"
column="SHORTNAME"
type="string"
not-null="false"
length="3"
/>
<property
name="updatetime"
column="UPDATETIME"
type="date"
not-null="false"
length="7"
/>
</class>
</hibernate-mapping>
但特殊情况下,主键可能由数字+字母,如:5555xxyx,我曾经想实现这种情况的,但没实现....
<column name="USER_ID" precision="22" scale="0" />
<generator class="identity" />
</id>
用identity