Currently, I am trying to update the eclipse-ee4j/cargotracker(originally it is a rewritten version of the Eric's DDD book sample) to the latest Jakarta EE 8:
https://github.com/hantsy/cargotracker/tree/jakartaee8
Personally, I want to expand WildFly as an alternative application server. But I encountered several wired issues between Payara/ElipseLInks and WildFly/Hibernate.
There is a Cargo entity that has a RouteSepcificaiton embeddable property that has departure and arrival Location(Entity) and arrival deadline date.
Dummy code fragments of the relations:
@Entity class Cargo{
@Embedded routeSepcification;
}
@Embedable class RouteSpecificition{
@ManyToOne Location origin
@ManyToOne Location destination
}
@Entity class Location{}
The book new cargo works well, but when I want to change to the new route using cargo.specifyNewRoute
, in another word, to update the route specification, it is not updated as expected.
The complete test code is here.
startTransaction();
var trackingId = new TrackingId("AAA");
Cargo cargo = cargoRepository.find(trackingId);
assertThat(cargo).isNotNull();
Location origin = locationRepository.find(SampleLocations.NEWYORK.getUnLocode());
Location destination = locationRepository.find(SampleLocations.HELSINKI.getUnLocode());
cargo.specifyNewRoute(new RouteSpecification(origin, destination, LocalDate.now()));
cargoRepository.store(cargo);
commitTransaction();
//verify in the new tx
startTransaction();
var result = this.entityManager.createQuery("select c from Cargo c where c.trackingId=:trackingId", Cargo.class)
.setParameter("trackingId", trackingId)
.getSingleResult();
assertThat(result.getTrackingId()).isEqualTo(trackingId);
assertThat(result.getRouteSpecification().getOrigin()).isEqualTo(origin);
assertThat(result.getRouteSpecification().getDestination()).isEqualTo(destination);
assertThat(result.getItinerary().getLegs()).hasSize(1);
commitTransaction();
The Arquillian test is failed on WildFly/Hibernate but passed on Payara/EclipseLinks.
question from:
https://stackoverflow.com/questions/65839254/wildfly-hibernate-update-an-embedded-property-failed 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…