Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jpa - Payara/EclipseLink: count on collection which owner is an Embedable return 0

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...