1 java类中定义属性的默认值并不能直接映射到数据库的定义当中
如 private String a="A";
public String getA(){};
数据库的a字段并没有default.
用annotations column中的columnDefinition可以解决
@Column(columnDefinition="varchar2(2) default '11'")
public String getA(){};
字段就可以存在默认值了
注意字段的类型必须指定,因为hibernate会把columnDefinition的内容直接写在生成标的ddl中,因此语法必须正确。
2 hql自动生成的sql很大,而且输出后不容易调试。
在框架中core-config.xml中的hibernateProperties段加入设定参数可以改变。
<prop key="hibernate.use_sql_comments">true</prop>//sql加注释
<prop key="hibernate.format_sql">true</prop>//sql格式化
输出结果见附件
- 描述: sql格式化
- 大小: 35.7 KB
分享到:
相关推荐
hibernate annotation hibernate3
这里面包涵了需要用Hibernate Annotation时,所需要的所有jar包! 现在我们公司在做web项目的时候,已经不用*.hbm.xml这种映射文件了,都是用Annotation(注解)方式来完成实体与表之间的映射关系,这样看起来比用...
hibernate annotation中文文档
hibernate annotation 中文文档
很全的Hibernate Annotation API文档,页面也很漂亮,太强大了。真的很实用!我以前找了好多,都不全,这个真的很不错,推荐一下。
NULL 博文链接:https://paladin1988.iteye.com/blog/1640340
hibernate annotation库所需要引入的三个jar包。
Hibernate Annotation
通过HibernateAnnotation技术就不用xml文件了
hibernate 注解 annotation 教程
Hibernate annotation 3.4 api CHM
该zip包含 hibernate3.3.2相关jar与文档,hibernate annotation3.3.4相关jar与文档。
学习JPA——Hibernate_Annotation使用实例学习JPA——Hibernate_Annotation使用实例学习JPA——Hibernate_Annotation使用实例
逐渐的Hibernate Annotation的映射方式也越来越盛行,相信过不了多久有可能会取代*.hbm.xml映射方式
hibernate annotation3.3 api 文档
java SSH项目 hibernate annotation
即利用hibernate注解后,可不用定义持久化类对应的*.hbm.xml文件,直接以注解方式写入在持久化类中来实现。 Hibernate annotation使用了ejb JPA的注解,所以,下面安装配置hibernate annotation环境时,需要导入ejb的...
springmvc + hibernate annotation 配置
hibernate annotation学习文档,帮助你学习hibernate