openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruslan <rusl...@gmail.com>
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?
> 

Nope.


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:
 
http://n2.nabble.com/file/n1574493/jpa_bug_foreign_key.zip
jpa_bug_foreign_key.zip 

I also hosted it here: http://fileurls.com/tjknjd

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:

jdk1.6.0_10
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: http://n2.nabble.com/Re%3A-Foreign-key-field-doesn%27t-get-populated-in-descendant-class-in-Join-Inheritance-tp1574111p1574493.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message