随笔分类 - Hibernate
摘要:QueryTranslatorImpl @Override public List list(SessionImplementor session, QueryParameters queryParameters) throws HibernateException { // Delegate to the QueryLoader... ...
阅读全文
摘要:看图想想相关的架构 1.查询表达式中的接口层次结构 2.CriteriaQuery 封装了传统查询的子句 3.Metamodel API 中的持久化类型的接口的层次结构 4. Metamodel API 中的持久化属性的接口的层次结构 5.元模型接口是持久化单元中的类型的容器 这个接口允许通过元模型
阅读全文
摘要:No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to av
阅读全文
摘要:Join Transaction The EntityManager.joinTransaction() API allows an application managed EntityManager to join the active JTA transaction context. This
阅读全文
摘要:一。什么时候会遇到1+N的问题? 前提:Hibernate默认表与表的关联方法是fetch="select",不是fetch="join",这都是为了懒加载而准备的。 1)一对多(<set><list>) ,在1的这方,通过1条sql查找得到了1个对象,由于关联的存在 ,那么又需要将这个对象关联的集
阅读全文
摘要:1.双向关系中使用mappedBy避免生成中间表(1).只有OneToOne,OneToMany,ManyToMany上才有mappedBy属性,ManyToOne不存在该属性;(2).mappedBy标签一定是定义在被拥有方(Group),他指向拥有方(User);@Entity@Table(name="t_group")public class Group { private int id; private String name; private Set users = new HashSet(); public Group(){ } ...
阅读全文
摘要:@Entity@Table(name="t_group")public class Group { private int id; private String name; public Group(){ } public Group(String name) { this.name = name; } @Id @GeneratedValue public int getId() { return id; } public void setId(int id) { ...
阅读全文
摘要:1.Field 'id' doesn't have a default value 原来是我的数据设计的时候,把主键的类型定义为int的,原本想是用自增的方式来的,可是由于自己的粗心,写sql语句的时候没有加上auto_increment,所以在数据存储的时候老是报Field 'id' doesn't have a default value,id根本就没有值啊!!2.Could not synchronize database state with session不能在两个sessionFactory中交叉操作public class User
阅读全文