openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Holloway <t...@mousetech.com>
Subject OptimisticException on items without version info
Date Wed, 18 Jun 2008 21:26:47 GMT
I've been getting OptimisticExceptions merging on the following:

	@Transactional
	public Trips save(final Trips trip) {
		if (trip.getTripId() > 0) {
			log.warn("SAVE TRIPS *** BEGIN ***");
			final Trips trip1 = entityManager.merge(trip);
			log.warn("SAVE TRIPS *** END ***");
			return trip1;
		} else {
			entityManager.persist(trip);
			for (TripStops stop : trip.getTripStops()) {
				stop.setTrips(trip); // Affirm parent
				entityManager.persist(stop);
			}
			return trip;
		}
	}

Digging around in the debugger indicates that one of the children has a
NoneVersionStrategy, so attempts to compare versions will
unconditionally fail even between an object and itself. I was expecting
it to use the StateComparisonVersionStrategy, actually.

I know that Kodo would attempt to do a pessimistic update of changed
fields by making the WHERE clause of the update contain the expected
values of all item fields.

Of course, the bigger issue is that no fields are expected to have been
changed at all - the merge was supposed to be doing a re-attach.

So the question is, what am I doing wrong here?

For a complete set of class definitions, see the file uploaded under
Jira issue# OpenJPA-626. The offending item is the TripStops class after
making Fay's suggested corrections.


Mime
View raw message