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,

Mitesh Meswani wrote:

Consider following code.

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)

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?

eclipselink-dev mailing list

Back to the top