Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EntityGraph not working in GlassFish
EntityGraph not working in GlassFish [message #1776574] Fri, 17 November 2017 19:57 Go to next message
B  J is currently offline B JFriend
Messages: 1
Registered: November 2017
Junior Member
I would like use Entity Graphs in EclipseLink and GlassFish.

    @Entity
    @NamedQueries({
         @NamedQuery(name = "invoice.all", query = "SELECT i FROM Invoice i")})


    @NamedEntityGraph(name = "graph.invoice",
                attributeNodes = {@NamedAttributeNode("invoiceNum")})

    @Table(name = "INVOICE")
    public class Invoice implements Serializable {
            private int id;
            private String bizonylatSzam;
            ...
        }

EntityManager em = getEntityManagerFactory().createEntityManager();
EntityGraph eg = em.createEntityGraph("graph.invoice");
List<Invoice> invoiceList =  em.createNamedQuery("invoice.all").setHint("javax.persistence.fetchgraph", eg).getResultList();

If I use javax.persistence.load graph everything OK, but if i use javax.persistence.fetchgraph I have an exception:

org.eclipse.persistence.exceptions.QueryException Exception Description: You must define a fetch group manager at descriptor (Invoice) in order to set a fetch group on the query (invoice.all)


In EclipseLink webpage write:

... using Weaving technologi..

Weaving and Java EE Application Servers

The default EclipseLink weaving behavior applies in any Java EE JPA-compliant application server using the EclipseLink JPA persistence provider. To change this behavior, modify your persistence.xml file (for your JPA entities or POJO classes) to use EclipseLink JPA properties, EclipseLink JPA annotations, or both.

If i add -javaagent:eclipselink.jar in GlassFish Admin console JVM options for dinamic weaving, I have get an exception when start GF.

I dont understand what is the problem. :(
Re: EntityGraph not working in GlassFish [message #1777555 is a reply to message #1776574] Thu, 30 November 2017 10:05 Go to previous messageGo to next message
Georgi Georgiev is currently offline Georgi GeorgievFriend
Messages: 1
Registered: November 2017
Junior Member
Hi there,

have you found any solution?
I'm struggling with the same problem.

Thanks,
Georgi
Re: EntityGraph not working in GlassFish [message #1778515 is a reply to message #1776574] Fri, 15 December 2017 14:26 Go to previous messageGo to next message
Gabriel Pascual is currently offline Gabriel PascualFriend
Messages: 31
Registered: April 2013
Location: Laval, France
Member
Hi all,

I have a similar problem with EntityGraph and Wildfly. I try to fetch an EntityGraph from a Criteria Query and I have this error:
 WARN  [MyDaO] (default task-24) null: javax.persistence.PersistenceException: Exception [EclipseLink-6112] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Fetch group cannot be set on report query.
Query: ReportQuery(referenceClass=MyEntityA )
FetchGroup(null){fieldA=> {class MyEntityB=FetchGroup(fieldA){}}, fieldB, fieldC=> {class MyEntityC=FetchGroup(fieldC){}}, fieldD=> {class MyEntityD=FetchGroup(fieldD){}}, fieldE, fieldF, fieldG, fieldH, fieldI}

I have some questions :

  • Can I use EntityGraph without Weaving ?
  • How can I change the type of query to use EntityGraph ?


Regards,

Gabriel


Software Development Engineer
Re: EntityGraph not working in GlassFish [message #1828600 is a reply to message #1776574] Sun, 14 June 2020 11:52 Go to previous messageGo to next message
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 124
Registered: July 2009
Senior Member
Anybody found a solution to this?

Sorry, but Eclipse, the Eclipse Foundation, the forums and EclipseLink support is going downhill for years...

[Updated on: Sun, 14 June 2020 11:56]

Report message to a moderator

Re: EntityGraph not working in GlassFish [message #1828646 is a reply to message #1828600] Mon, 15 June 2020 17:19 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1388
Registered: July 2009
Senior Member
Ouch. I can't refute your feeling, I might suggest using Oracle support or other paid support contracts that include or use EclipseLink. I have the feeling they have devs that work on the project but just aren't active on the forums or the open source side of things.

The original question, while dated and missing key details, seems to imply that dynamic weaving did not occur. The persistence unit is either container managed, which on Glassfish would allow it to be woven, or is customer managed, which it seems to be here, and likely not setup so that EclipseLink can weave it - or that EclipseLink knows it was woven. Solution is likely just to use static weaving, or tell EclipseLink it was woven already woven through
eclipse.weaving and eclipselink.weaving.fetchgroups properties, ensuring they are set to true. Logging would then indicate if EclipseLink finds issues when deploying the persistence unit with these settings.

Other follow up questions don't seem related. "Fetch group cannot be set on report query", while it mentions fetch group is something different from the original post - report queries were used to return partial data queries, and so didn't support fetch groups in the same way. EclipseLink 2.5.2 is old, and I don't remember specific on if/when that changed, as all JPA queries were eventually required to allow fetch groups. This could be a bug in one specific use case (returning an entity with 'other' data), an error in the code, or just using an outdated version with incomplete support.

For anyone else, I'd advice creating new posts with specifics. I'd also try simplifying fetch group usage to queries that return simple results, like a find by id type query. Then expand on things to figure out if the issues are with fetch group, the query itself or the environment it is run (weaving for example).
Previous Topic:Using Eclipselink with Streams in parallel gives NullPointerException
Next Topic:Polyglot Composite PU - OneToMany/ManyToMany
Goto Forum:
  


Current Time: Sun Jun 20 17:15:09 GMT 2021

Powered by FUDForum. Page generated in 0.02365 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top