---
title: "Hibernate Annotation的 *ToOne默认的FetchType是EAGER的"
author: "NicholasBugs"
date: "2008-07-23T13:50:58Z"
tags: []
slug: "hibernate-annotation-toone-fetchtype-eager"
draft: false
lastmod: "2008-07-23T13:50:58Z"
id: 218551
url: "https://nicholasbugs.iteye.com/blog/218551"
---

Hibernate Annotation的 *ToOne默认的FetchType是EAGER的

public class Entry{
...
@ManyToOne(targetEntity = User.class, fetch = FetchType.LAZY)
如果不加“fetch = FetchType.LAZY” 就会生成一个连表sql.
    /**
     * lazy load this property by proxy
     */
    @JoinColumn(name="USERID")
    @LazyToOne(LazyToOneOption.NO_PROXY)
    private User author;
...
}