openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruslan <>
Subject Re: Foreign key field doesn't get populated in descendant class in Join Inheritance
Date Tue, 25 Nov 2008 00:29:13 GMT

Kevin Sutter wrote:
> I see that you are using LAZY fetch type, so that's a hint to us not to go
> out and load the Book entities until they are requested.  But, if these
> Book entities were previously persisted and still available in the
> persistent context, they can be filled in.  The LAZY fetch type is a hint
> that you don't need these fields filled in.  It does not mean that they
> won't be filled in, if the data is already available.
> So, is there any chance that your "normal" books were already available in
> the persistence context when you looked at the values and the electronic
> books were not in the persistence context?

Nope. It's fresh start of application where I load instance of AuthorsEntity
via EntityManaget.find(). As you mentioned AuthorsEntity.books is defined as
lazily loadable so it gets loaded when I call AuthorsEntity.getBooks(). It
loads all "normal" books, but when I access electronic book in books' List
it makes another query to get data for ElectronicBooksEntity.

Kevin Sutter wrote:
> Also, when you check for the value of the author field, is it null all the
> time? 

Yes. It's null.

Kevin Sutter wrote:
> That is, even if you attempt to access the author field via the getter
> method on an electronic book, it won't get retrieved and filled in?


Kevin Sutter wrote:
> Or, are you just looking at the field via a debugger or dump routine?

Both, but I know that only call to getter method causes query on lazily
loadable collections.

I created small project which uses Derby and demonstrates this problem. Here
it is: 

I also hosted it here:

TEST 1 shows problem described in this topic. I also created second
test-case which demonstrates that EntityManager.merge() call on
AuthorsEntity whose name was changed via .setName() causes cascade update of
ALL books even though they haven't been changed.

All two issues go away if I specify PCEnhancer via -javaagent option. Which
makes me think that "Java 6 class retransformation" described in the
documentation doesn't work as intended (or I don't understand something) in
terms of control of "dirtiness" of objects.

My environment is:

apache-openjpa-1.3.0-SNAPSHOT by October 24 of 2008 (but I tried stable 1.2
as well)
Windows XP SP3

Thank you a lot in advance!
View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message