| Summary: | Cannot merge: org.eclipse.persistence.exceptions.OptimisticLockException | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Bernard Missing name <bht237> | ||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||
| Status: | CLOSED INVALID | QA Contact: | |||||||
| Severity: | major | ||||||||
| Priority: | P3 | CC: | tom.ware | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Bernard Missing name
Created attachment 214018 [details]
EclipseLink NetBeans project in zip file
Created attachment 214019 [details]
Hibernate Maven project in zip file
Here is some info about maven: http://wiki.eclipse.org/EclipseLink/Maven There is also an initiative to create an Eclipse Maven repository. When that becomes available, we plan to make use of it. In general, I suggest posting issues to either the mailing list or the forum prior to filing a bug. Doing that will increase the number of people that will see the issue and therefore increase the chance of finding a solution or a workaround. This exception is being thrown because you are calling merge on an Agreement that has not had a version number set on it. (since version is an int, this means the value is 0) An agreement with the same id is in the DB with a higher version number from your earlier persist. The OptimisicLockException seems correct to me. The best way to get around this is to copy the version number as well in public Agreement(DetachedAgreement detachedAgreement, EntityManager em) The difference in behavior between EclipseLink and hibernate can likely be attributed to when the products choose to increment the version field. EclipseLink will do it on flush. (I am guessing hibernate wait until commit) In any case, the advice above should work on both. Thanks Tom for your explanation which makes 100% sense to me. Hibernate does not fail because it starts the version number with 0 so there is no difference between the persisted and detached versions in this special case. Sorry, It was only Hibernate's behavior that encouraged me to file an issue. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |