openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <>
Subject Re: Foreign key field doesn't get populated in descendant class in Join Inheritance
Date Mon, 24 Nov 2008 22:38:47 GMT
Hi Ruslan,
Sorry for the delay in responding.  Just so many items to work on...

I don't see anything incorrect with your Entity definitions below.  I guess
my only observation is how are you determining that various fields are null
or filled in?  And, at what point in your processing are you checking for
these values?

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?

Also, when you check for the value of the author field, is it null all the
time?  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?
Or, are you just looking at the field via a debugger or dump routine?

Another question is how are you creating your ElectronicBookEntities?  I
don't see a constructor for this class.  Nor, do I see a factory method like
I do in the AuthorEntity for normal BookEntities.  Maybe this gets back to
my earlier questions on the testing that you are attempting and how are you
validating that fields are or are not filled in?

Thanks for your patience.  Now that we've started a thread, hopefully the
responses will be a bit quicker...  :-)


On Tue, Nov 18, 2008 at 3:55 AM, Ruslan <> wrote:

> Hi guys.
> Looks  like I'm having trouble confirming my email here. Let's try one
> more time... Sorry if you saw two messages.
> I  have  a  question  about  join  table inheritance. In few words the
> problem  is that foreign key field doesn't get set in descendant class
> in Join Inheritance.
> I have 3 tables: authors, books and electronic_books.
> Here is SQL script:
> AuthorsEntity:
> BooksEntity:
> ElectronicBooksEntity:
> In  my  test  case I have one author who has 3 books - 2 regular books
> and one electronic.
> When I fetch that single instance of AuthorsEntity I see that for some
> reason   field   of   instance   of   an   object
> ElectronicBooksEntity  equals  null. But remaining 2 instances of base
> class  BooksEntity have properly set 'author'. Initially I thought ALL
> fields   of   base   class   won't   be   set   but   it   turns   out
>  and  ElectronicBooksEntity.title  have valid
> values.
> Am I missing something in definition of my descendant class ?
> Thanks!!
> / Ruslan

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message