openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ljnelson <ljnel...@gmail.com>
Subject Re: insertable/updatable = false question
Date Thu, 13 Aug 2009 17:24:46 GMT

On Thu, Aug 13, 2009 at 1:10 PM, crispyoz (via Nabble) <
ml-user+243560-833017765@n2.nabble.com<ml-user%2B243560-833017765@n2.nabble.com>
> wrote:

> I didn't quite get what you were trying to describe


Let me try again.

I have multiple mappings for the same column.  Of those multiple mappings,
only one may be mutable.

So E2 has a @Basic *mutable* mapping for its "x" column and its "x"
field--you can set the "x" field as many times as you like to whatever value
you like (but read on).  At insert or update time, your changes will be
persisted.  Although I don't explicitly specify it, it is insertable = true
and updatable = true.

Then E2 has a lazy @ManyToOne mapping for its "e1" *field* whose @JoinColumn
is an *immutable* mapping to the "x" column.  That is, you could, I suppose,
set the e1 field to an E1 of your choice, if you wanted, but since that
mapping is marked as "insertable = false, updatable = false", the E1 you
install in this manner will be ignored at insert and at update time.  So if
you stuck an E1 in there, then saved the E2, your E1 would not be persisted.

It should follow from this--at least according to my reading--that I should
be able to set the "x" field to a value that is the primary key of an E1,
and set the "e1" field to null.  So let's say I set e2.x to 5, and let's say
that there's an E1 in the database with a PK of 5.

It should be the case that if I merge e2, I should now be able to say
e2.getE1(), and I should get back an E1 as computed by the JPA relationship
machinery.

So, in other words, it should be possible to create an E2 with, say, a value
for its "x" field of 5, and then, after a merge and perhaps a flush, you
SHOULD be able to say to that E2, "OK, give me your related E1, even though
I never specified it", and because you've supplied the raw materials for the
mapping, it should be able to lazily give you that E1 reference.

But I am not seeing this behavior.  I am unclear as to whether it is a bug
or a part of the specification that I am reading badly (it sure wouldn't be
the first time :-\).

Thanks,
Laird

-- 
View this message in context: http://n2.nabble.com/insertable-updatable-%3D-false-question-tp3439111p3439449.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

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