1.在bo中这种方式
@Entity @Table(name = "INTERFACE_APP")类继承 implements java.io.Serializable主键get方法前写: @GenericGenerator(name = "generator", strategy = "uuid.hex") @Id @GeneratedValue(generator = "generator") @Column(name = "user_id", unique = true, nullable = false, length = 32)其他列get方法前写:@Column(name = "CURRENT_LOGON_DATE", length = 3594)如果是日期类型,没有长度然后在hibernate.cfg.xml中配置
<hibernate-configuration> <session-factory> <mapping class="com.wondersgroup.sabic.gircs.interfaceinfo.bo.InterfaceApp" /> </session-factory></hibernate-configuration> 2.首先创建一个类public class MacroCollectRpt然后写一个MacroCollectRpt.hbm.xml
<hibernate-mapping package="com.tmk.macro.model">
<class name="MacroCollectRpt" table="MACRO_COLLECT_RPT"> <id column="MACRO_COLLECT_RPT_ID" name="id" type="integer" > <generator class="com.wonders.gmis.common.id.IntegerIdGenerator"> <param name="idName">MACRO_COLLECT_RPT_ID</param> </generator> </id> <property column="MONTH" length="7" name="month" not-null="true" type="date" /></class>
</hibernate-mapping>