hibernate3学习笔记(十) SQL支援 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-20
. <![CDATA[29. select {user.*} from User user where user.age > :age30. ]]>31. <return alias="user" class="com.hb3.pack_01.model.User"/>
32. </sql-query>
33.34.</hibernate-mapping>
运行结果: 17:20:40,859 WARN ConfigurationFactory:127 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/Java/MyEclipse%206.0/workspace/hb3demo/ehcache-1.2.3.jar!/ehcache-failsafe.xml17:20:41,281 WARN EhCacheProvider:93 - Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.17:20:41,312 WARN EhCacheProvider:93 - Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.Hibernate: select user.id as id0_0_, user.name as name0_0_, user.age as age0_0_ from User user where user.age > ?28 shenbin24 chenyan23 shenyi23 yangye22 chenyongHibernate: select user.id as id0_0_, user.name as name0_0_, user.age as age0_0_ from User user where user.age > ?28 shenbin24 chenyan23 shenyi23 yangye22 chenyong hibernate3学习笔记(十) SQL支援(3)时间:2011-02-02 csdn 沈斌另外,我们还可以自定义insert、update、delete时的SQL文而不使用Hibernate3自动生成的SQL文。 修改User.hbm.xml文件如下: 1.<?xml version="1.0" encoding="UTF-8"?>2. 3.<!DOCTYPE hibernate-mapping PUBLIC4. "-//Hibernate/Hibernate Mapping DTD 3.0//EN"5. "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 6. 7.<hibernate-mapping> 8. <class name="com.hb3.pack_01.model.User" table="user"9. dynamic-insert="true"10. dynamic-update="true"11. > 12. <id name="id" column="id" type="java.lang.Integer" unsaved-value="null"> 13. <generator class="native" /> 14. </id> 15.16. <property name="name" column="name" type="java.lang.String" /> 17.18. <property name="age" column="age" type="java.lang.Integer" /> 19.20. <sql-insert> 21. <!-- INSERT INTO user (name, age) VALUES (?, ?) --> 22. INSERT INTO user VALUES (?, ?) 23. </sql-insert> 24. <sql-update> 25. UPDATE user SET name=?, age=?, WHERE id=?26. </sql-update> 27. <sql-delete> 28. DELETE FROM user WHERE id=?29. </sql-delete> 30.31. </class> 32.33. <query name="com.hb3.pack_01.model.User.QueryUser"> 34. <![CDATA[35. from User as user where user.age > :minAge36. ]]> 37. </query> 38.39. <sql-query name="com.hb3.pack_01.model.User.SQLQueryUser"> 40. <![CDATA[41. select {user.*} from User user where user.age > :age42. ]] |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于hibernate3学习笔记(十) SQL支援 - 编程入门网的所有评论