<mailto:
saasira@xxxxxxxxx>> wrote:
Hi Qayyum,
I can offer the below explanations for two of your questions:
1. for the delete use case, you can write a JPQL query to delete
the record, example:
String queryString= "DELETE OBJECT(BO) FROM " +
businessObject.getClass().getCanonicalName()+ " BO " + "WHERE
BO.id=:" + businessObject.getId();
Query query=em.createQuery(queryString);
int result= em.executeUpate(query);
return result==1?true:false;
however,there is a small downside to this; we don't get an
OptimisticLockException when we try to delete a record that has
been changed just before we executed this delete query. So we
may never see certain updates to the deleted objects; if it
crucial for your use case to always make sure that the object
being deleted is in a certain state then, you need to write
additional filter conditions n the where clause like :
BO.version=businessObject.getVersion, and depending on the
returned value, if zero, we have to assume that the deletion
failed because the record has been updated by some other
parallel transaction and that the version number might have
changed; and hence rollback the current activity and tell the
user to start the transaction afresh. ofcourse, this is all
required if you want to make sure that you always delete the
latest version of the object.
2. Yes, I too observed that eclipselink is generating an
uncessary join when all I want is a reference to the id that my
table-in-question already has as a foriegn key reference. you can view the mail thread I posted earlier
at:
http://www.nabble.com/unnecessary-join-made-in-case-of-Many%3C--%3EMany-relation-tp24679954p24703970.html
I did not raise a bug for this as suggested by James since I
myself am not convinced at that time that this is really an
issue with eclipselink and attributed to my data model design
where we have too many eagerly loaded objects.
Looking at your issue, I'm thinking to revisit this and verify
that the issue is infact produced by eclipselink, and if yes, I
will raise a bugzilla request.
Regards,
Samba
On Fri, Dec 25, 2009 at 1:47 PM, jz <
jehanzeb.qayyum@xxxxxxxxx