ex:
class name=”com.hostel.db.entity.log.LogId” table=”LOG” schema=”TEGUAN”>
'composite-id>
'key-property name=”logId” type=”java.lang.String”>
'/key-property>
'key-property name=”logData” type=”java.lang.String”>
'/key-property>
'key-property name=”logType” type=”java.lang.String”>
'/key-property>
'key-property name=”logContent” type=”java.lang.String”>
'/key-property>
'key-property name=”logUser” type=”java.lang.String”>
'/key-property>
'key-property name=”logIp” type=”java.lang.String”>
'/key-property>
"/coposite-id>
'/class
通过这样,只需要操作一个类来完成。这样对于使用criteria来查询查询是个不错的选择;
使用Criteria查询不能通过主健进行查询(兴许是笔者自己太弱了),这时就首先需要把主健字段屏蔽掉。如下代码:
criteria.add(Example.create(hostel)
.enableLike(MatchMode.ANYWHERE) //模糊查询
.excludeProperty(”registerdate”) //取消按照注册时间、审核时间、旅馆ID 进行示例查询
.excludeProperty(”auditdate”)
.excludeProperty(”gasthausId”));
这样就可以屏蔽掉按某些字段查询,然后在通过criteria.add(Expression.eq(”",”"))来进行查询了;
注:如果查询字段没有通过.excludeProperty屏蔽示例查询,那么 .enableLike(MatchMode.ANYWHERE) //模糊查询 将会自动进行模糊查询,而不用使用Expression.like(”字段名”,”%”+值+”%”);