---
title: "Hibernate annotation Lazy的默认值的不同"
author: "allenwei"
date: "2008-08-13T23:42:40Z"
tags: []
categories: ["企业架构"]
slug: "hibernate-annotation-lazy"
draft: false
lastmod: "2008-08-13T23:42:40Z"
id: 227853
url: "https://allenwei.iteye.com/blog/227853"
---

经过测试发现Hibernate annotation中@ManyToOne,@OneToMany,@OneToOne中lazy的默认值是不同的

 

@OneToMany 默认Lazy为true

@ManyToOne,@OneToOne 默认lazy为false

 

在设置@ManyToOne的时候我们一般都会设置Lazy=true

 

一般不会在@ManyToOne,@OneToOne考虑这个问题

 

但实际hibernate进行load是时候是把一端也load出来的

 

 

希望大家以后写得时候注意