title: How can I make a JPA OneToOne relation lazy
body: <p>In this application we are developing, we noticed that a view was particularly slow. I profiled the view and noticed that there was one query executed by hibernate which took 10 seconds even if there only were two object in the database to fetch. All <code>OneToMany</code> and <code>ManyToMany</code> relations were lazy so that wasn't the problem. When inspecting the actual SQL being executed, I noticed that there were over 80 joins in the query. </p>
  
  <p>Further inspecting the issue, I noticed that the problem was caused by the deep hierarchy of <code>OneToOne</code> and <code>ManyToOne</code> relations between entity classes. So, I thought, I'll just make them fetched lazy, that should solve the problem. But annotating either <code>@OneToOne(fetch=FetchType.LAZY)</code> or <code>@ManyToOne(fetch=FetchType.LAZY)</code> doesn't seem to work. Either I get an exception or then they are not actually replaced with a proxy object and thus being lazy.</p>
  
  <p>Any ideas how I'll get this to work? Note that I do not use the <code>persistence.xml</code> to define relations or configuration details, everything is done in java code.</p>