Changing the id of a managed entity

View: New views
6 Messages — Rating Filter:   Alert me  

Changing the id of a managed entity

by Farrukh Najmi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Guys,

I have a situation where I need to change the id of a manged entity
within my transaction.
I realize this seems questionable. What is the best way to accomplish this?

Thanks for your help.

--
Regards,
Farrukh

Web: http://www.wellfleetsoftware.com



Re: Changing the id of a managed entity

by Craig L Russell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Farrukh,

The best way I know of is to "simply" write a JDBC program to make the  
change without involving JPA in the code. The tricky part is to notify  
caches. JPA implementations should be able to handle this kind of  
change transparently to application code.

Craig

On Aug 7, 2009, at 8:46 AM, Farrukh Najmi wrote:

> Hi Guys,
>
> I have a situation where I need to change the id of a manged entity  
> within my transaction.
> I realize this seems questionable. What is the best way to  
> accomplish this?
>
> Thanks for your help.
>
> --
> Regards,
> Farrukh
>
> Web: http://www.wellfleetsoftware.com
>
>
Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@...
P.S. A good JDO? O, Gasp!



smime.p7s (3K) Download Attachment

Re: Changing the id of a managed entity

by Marina Vatkina :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Farrukh,

You can delete the old one and insert the new, copying over the field values.

Regards,
-marina

Farrukh Najmi wrote:
> Hi Guys,
>
> I have a situation where I need to change the id of a manged entity
> within my transaction.
> I realize this seems questionable. What is the best way to accomplish this?
>
> Thanks for your help.
>


Re: Changing the id of a managed entity

by Farrukh Najmi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Craig,

That would be very difficult in my server to do. Any other way I could
do this via JPA? Thanks for the suggestions.

Craig L Russell wrote:
> Hi Farrukh,
>
> The best way I know of is to "simply" write a JDBC program to make the
> change without involving JPA in the code. The tricky part is to notify
> caches. JPA implementations should be able to handle this kind of
> change transparently to application code.
>


--
Regards,
Farrukh

Web: http://www.wellfleetsoftware.com



Re: Changing the id of a managed entity

by Mitesh Meswani :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can delete the entity and reinsert with new ID.

Farrukh Najmi wrote:

>
> Hi Craig,
>
> That would be very difficult in my server to do. Any other way I could
> do this via JPA? Thanks for the suggestions.
>
> Craig L Russell wrote:
>> Hi Farrukh,
>>
>> The best way I know of is to "simply" write a JDBC program to make
>> the change without involving JPA in the code. The tricky part is to
>> notify caches. JPA implementations should be able to handle this kind
>> of change transparently to application code.
>>
>
>

Re: Changing the id of a managed entity

by Farrukh Najmi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Many thanks! This did the trick. Thanks to all for your kind help.

Marina Vatkina wrote:

> Hi Farrukh,
>
> You can delete the old one and insert the new, copying over the field
> values.
>
> Regards,
> -marina
>
> Farrukh Najmi wrote:
>> Hi Guys,
>>
>> I have a situation where I need to change the id of a manged entity
>> within my transaction.
>> I realize this seems questionable. What is the best way to accomplish
>> this?
>>
>> Thanks for your help.
>>
>


--
Regards,
Farrukh

Web: http://www.wellfleetsoftware.com