Without going into gory details of my application here is my use case:
* I have an existing entity in db
* Within a transaction the following occurs:
o The existing entity gets read by transaction
o The existing entity *MAY* get removed by transaction (or not)
o A new entity is inserted with the same id. The code to do
that needs to know whether to use a merge or insert. One way
to decide is to know if the netity was deleted or not. If it
was deleted do an insert otherwise do a merge.
I am curious why there is no method(s) to determine state of en entity
within an EntityManager in the API.
Thanks.
Markus KARG wrote:
> AFAIK JPA does not contain a means of detection wheter an entity has been
> removed, but only whether an instance of an entity is present or not. Also I
> do not see a sense in such a detection. What shall it be good for?
>
>
>> -----Original Message-----
>> From: Farrukh Najmi [mailto:farrukh_at_wellfleetsoftware.com]
>> Sent: Sonntag, 7. Dezember 2008 23:14
>> To: persistence_at_glassfish.dev.java.net
>> Subject: Determining if entity has been removed
>>
>> Dear colleagues,
>>
>> How can I determine whether an entity has been removed within the
>> EntityManager?
>> More generally is there any way in the JPA API to determine status of
>> an
>> entity within
>> the EntityManager? It does not appear to be possible. If not possible,
>> is this something useful to
>> consider for future version of API?
>>
>> Thanks.
>>
>> --
>> Regards,
>> Farrukh Najmi
>>
>> Web: http://www.wellfleetsoftware.com
>>
>
>
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com