1. 在实际开发中需要在hbm文件中使用的type属性值是指定的类型。那
么指定的类型一般的是基于hibernate的类型。
2. 当然在实际过程中也可以在hbm文件中指定java类型。
public class DataType { ???private long id; ???????private boolean tag; ?????????????private Date createDate; ???private char vip; ?????private Timestamp logTime; ??private byte[] description; ???….}
<hibernate-mapping> ???<class name="cn.itcast.hibernate.datatype.DataType" table="datatype"> ????<id name="id" column="id" type="long"> ??????<generator class="increment"></generator> ????</id> ????<property name="tag" column="tag" type="boolean"></property> ????<property name="createDate" column="createDate" type="date"></property> ????<property name="vip" column="vip" type="character"></property> ????<property name="logTime" column="logTime" type="timestamp"></property> ????<property name="description" column="description" type="binary"></property> ?</class></hibernate-mapping>
流类型 ????FileInputStream in = new FileInputStream(new File("测试文档.txt")); ????int length = in.available(); ????byte[] b = new byte[length]; ????in.read(b);时间戳类型 ?????new Timestamp(System.currentTimeMillis())查询的排序 ?????session.createQuery("from DataType as d order by d.id asc");分页 ?????query.setFirstResult(2); ?????query.setMaxResults(2);方法比较 ?????list()/iterator()的区别
Hibernate3映射数据类型
原文地址:https://www.cnblogs.com/loaderman/p/10037083.html