Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] A Question expected behavior for callback events

Hello Mitesh,

EclipseLink by default performs updates before deletes since there are some instances when foreign keys need to be nulled out before an object can be deleted. If EclipseLink does issue the update statement, it is not a false entry, and could be considered incorrect not to issue the preUpdate. EclipseLink's UnitOfWork can configured to perform deletes before updates, avoiding the preUpdate event if required using the UnitOfWork shouldPerformDeletesFirst(true) method which can be set using the PostAcquireUnitOfWork SessionEvent. It might be a good to file a feature to add a property for this at the persistence.xml or EntityManager level.

Best Regards,
Chris

Mitesh Meswani wrote:
Hi,

Consider following code.

          tx.begin();
Employee e = em.find(Employee.class, EMPLOYEE_PK); // Find an entity
          e.setName("foo");    // Mutate it
em.remove(e); //Remove the entity (Looks silly here but a possibility)
          tx.commit();

I was expecting that a preUpdate event would not be raised for such case. EclipseLink does raise it. I am not able to think of a use case where the event can be useful. Infect if some one is performing audit logs on preUpdate events, this can actually trigger false entries. What do others think about this scenario?

Thanks,
Mitesh
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev


Back to the top