Hibernate命名查询语句定义
使用Hibernate的HQL常常需要在Java代码中写字符串查询语句,为了使业务逻辑和查询语句分离,可以把字符串查询语句定义在映射文件中。
?
/**Output:
Hibernate: select customer0_.ID as col_0_0_ from CUSTOMERS customer0_ where customer0_.NAME like ?
Hibernate: select customer0_.ID as ID1_0_, customer0_.NAME as NAME1_0_ from CUSTOMERS customer0_ where customer0_.ID=?
Customer Id:27 name:Bruce
Hibernate: select customer0_.ID as ID1_0_, customer0_.NAME as NAME1_0_ from CUSTOMERS customer0_ where customer0_.ID=?
Customer Id:29 name:Bird
Hibernate: select customer0_.ID as ID1_0_, customer0_.NAME as NAME1_0_ from CUSTOMERS customer0_ where customer0_.ID=?
Customer Id:31 name:Bruce Chen
Hibernate: select customer0_.ID as ID1_0_, customer0_.NAME as NAME1_0_ from CUSTOMERS customer0_ where customer0_.ID=?
Customer Id:32 name:BB
*/?