Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Exception in order by clause after migrating to eclipselink 1.2release

Hi,

 

I have migrated to eclipselink 1.2 version (to be precise 1.2.0.v20091016-r5565).

 

I have a simple entity which has association with itself. The structure is defined below.

 

@Entity

@NamedQuery(name = "Emp.findAll", query = "SELECT DISTINCT emp from Emp emp order by emp.isManager ASC")

public class Emp implements Serializable {

           

            …….//Some fields

 

            @Column(name = "IS_MANAGER")

            private String isManager;

           

            @ManyToOne(cascade=CascadeType.REFRESH)

            @JoinColumn(name = "MANAGER_NO")

            private Emp manager;

           

……//Some more fields

 

            public Emp getManager() {

                        return this.manager;

            }

            public void setManager(Emp mgr) {

                        this.manager = mgr;

            }

            public String getIsManager() {

                        return isManager;

            }

            public void setIsManager(String isManager) {

                        this.isManager = isManager;

            }

}

 

When running with eclipselink 1.1 when the named query Emp.findAll iit works all fine, however with 1.2 version I started getting exception

 

Exception [EclipseLink-8030] (Eclipse Persistence Services - 1.2.0.v20091016-r5565): org.eclipse.persistence.exceptions.JPQLException

Exception Description: Error compiling the query [Emp.findAll: SELECT DISTINCT emp from Emp emp order by emp.isManager ASC], line 1, column 46: unknown state or association field [isManager] of class [com.arisglobal.aglitepq.entity.Emp].

      at org.eclipse.persistence.exceptions.JPQLException.unknownAttribute(JPQLException.java:457)

      at org.eclipse.persistence.internal.jpa.parsing.DotNode.validate(DotNode.java:78)

      at org.eclipse.persistence.internal.jpa.parsing.OrderByItemNode.validate(OrderByItemNode.java:52)

      at org.eclipse.persistence.internal.jpa.parsing.OrderByNode.validate(OrderByNode.java:72)

      at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:214)

      at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:187)

      at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:177)

      at org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree.populateReadQueryInternal(JPQLParseTree.java:110)

      at org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree.populateQuery(JPQLParseTree.java:84)

      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:170)

      at org.eclipse.persistence.internal.jpa.JPAQuery.processJPQLQuery(JPAQuery.java:106)

      at org.eclipse.persistence.internal.jpa.JPAQuery.prepare(JPAQuery.java:90)

      at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:464)

      at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:430)

      at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:1747)

      at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:409)

      at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)

      at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)

      at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:233)

      at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:269)

      at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:146)

      at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:198)

      at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:186)

 

 

I suspected the self reference to the entity (“manager” field) and removed it to find everything working fine. However this is a test example and we have many entities where self reference is required. Not sure how to change the query to make it work.

 

Any help regarding this is appreciated.


Thanks,
Shashi


Back to the top