Currently, I am trying to update the eclipse-ee4j/cargotracker to the latest Jakarta EE 8:
https://github.com/hantsy/cargotracker/tree/jakartaee8
There is a Cargo entity that has an Itinerary embeddable property that has a list of Leg(Entity).
Dummy code fragments of the relations:
@Entity class Cargo{
@Embedded itinerary;
}
@Embedable class Itinerary{
@OneToMany List<Leg> legs
}
@Entity class Leg{}
When counting the legs of a Cargo, the following works on both WildFly and Payara, check the complete testing codes here:
var count = cargoRepository.find(trackingId).getItinerary().getLegs().size();
But I tried to use JPQL or native query, neither worked on Payara/EclipseLink, both return 0, but they worked well on WildFly/Hibernate.
this.entityManager.createQuery("select count(e) from Cargo c join c.itinerary.legs e where c.trackingId = :id").setParameter("id", trackingId).getSingleResult()
this.entityManager.createNativeQuery("select count(*) from Leg where cargo_id = ?1").setParameter(1, cargo_id).getSingleResult();
question from:
https://stackoverflow.com/questions/65839382/payara-eclipselink-count-on-collection-which-owner-is-an-embedable-return-0 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…