My entity was indeed detached when I observed the behavior.
-----Original Message----- From: Michael Dick [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 20, 2007 12:12 PM To: [email protected] Subject: Re: Issues with FetchType.LAZY for Lob fields It sounds like the entity is getting detached before you load the @Lob field. As Nick said the entity could be detached if you accidentally close the EntityManager, or call EntityManager.clear(). The entity may also be detached when a JTA transaction completes if you're using a Transaction scoped PersistenceContext. Could provide a little more detail on what the application is doing? There might be other scenarios that cause the entity to be detached that you're running into. -Mike On Nov 19, 2007 9:31 PM, Nick Johnson <[EMAIL PROTECTED]> wrote: > Just in general, I've had similar behaviour to that happen if I > inadvertently closed the EntityManager that I had used to grab the > Entity before reading the lazy-loaded field. > > Nick > > On Mon, 19 Nov 2007, Gul Onural wrote: > > > > > I have a @Lob member variable in one of my Entities. If I annotate > > the field fetch=FetchType.LAZY and try to get its value using > > variable's get method, I always get null. > > > > > However, if I change the fetch to be EAGER (without any other change > > in the entire code), I get the value I supposed to get. > > > > Is there a known issue w.r.t the LAZY fetch type in general or am I > > missing something simple? > > > > > > @Lob > > @Basic(fetch = FetchType.LAZY) > > private String address; > > > > public String getAddress() { > > return this.address; > > } > > > > -- > "Courage isn't just a matter of not being frightened, you know. It's > being afraid and doing what you have to do anyway." > Doctor Who - Planet of the Daleks > This message has been brought to you by Nick Johnson 2.3b1 and the > number 6. > http://healerNick.com/ http://morons.org/ http://spatula.net/ >
