Hi,

Calling merge on a 'new' entity is one of the more error prone aspects of
JPA. The patch you've proposed will resolve the issue in your scenario but
it could introduce problems in other scenarios.

The change you made deals with what assumptions OpenJPA can make when we
find a field that is set to null in a 'new' entity.

Currently if the field is null and we can assume that null fields were not
loaded we ignore the field. With your change we would ignore such a field if
the collection is empty or null (and we can assuming nulls were not loaded).
Where this goes wrong is if the application intended to set the field to an
empty collection (if I'm reading the code correctly it's a bit more
complicated than that, but bear with me). There's room for improvement in
the way we handle merging new instances and we might be able to do something
similar to your patch, but I'd have to take a closer look before I can sign
off on it.

Instead of updating the OpenJPA code, have you tried using lazy
initialization on the field (I'm assuming you initialize it to an empty
collection).

-mike


On Thu, Oct 2, 2008 at 4:14 AM, egoosen <[EMAIL PROTECTED]> wrote:

>
> Fixed the compilation problem in my previous post, by running: mvn clean
> package
> --
> View this message in context:
> http://n2.nabble.com/Non-dirty-entity-version-field-update-SUPER-URGENT%21%21%21-tp1120307p1133460.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

Reply via email to