For my 2c worth. Delete by query might be cheaper, but for me it breaks the
ORMS model. The model relationships should manage all aspects of the model.
Performing a query in a true ORMS model seems to be a patch up job.

Just my 2c,

Chris


-----Original Message-----
From: Ravi Palacherla [mailto:ravi.palache...@oracle.com] 
Sent: Thursday, 13 August 2009 9:41 PM
To: users@openjpa.apache.org
Subject: RE: Delete or merge, update or merge ?

Hi ,

I guess, If you mergeA with one less B , then the association between A and
B will be lost but the instance of B will not be deleted.

If you call em.remove(B) then the instance of B (corresponding row in B)
will be deleted.

Delete by query also should remove the instance of B.
If memory is a constraint and I do not want to pull all the instances of B
into memory then I will go with delete by query. I personally think ( I
could be wrong), delete by query is better in terms of memory and
performance.

Regards,
Ravi.

-----Original Message-----
From: Jean-Baptiste BRIAUD -- Novlog [mailto:j-b.bri...@novlog.com] 
Sent: Thursday, August 13, 2009 3:24 AM
To: users@openjpa.apache.org
Subject: Re: Delete or merge, update or merge ?

up : any advice on that point ?

On Aug 8, 2009, at 08:57 , Jean-Baptiste BRIAUD -- Novlog wrote:

> Hi,
>
> say I have one instance to delete, an instance of B knowing that A  
> contains one to many B.
>
> Should I merge A with one less B, that should delete the required B  
> or should I explicitly delete that B with a delete by query or  
> should I use the remove(thatB) API ?
> What are the differences in term of design, memory, performance, ... ?
>
> Quedtion also apply in case of a new B : merge on A, insert by query  
> or persist(thatB) on entityManager ?
>
> The same question apply to merge or update by query one B.
>
> Thanks !
>


Reply via email to