Thank you for your reply,hannehomuth.
but when I using native query, the program throws the NullPointerException, how can I solve this problem. (the query object is NOT NULL)
Code:
Query query = entityManager.createNativeQuery("SELECT group.*,level FROM GROUP group "+
"WHERE GROUP_TYPE = 'ACTIVE' START WITH (PARENT_GROUP_ID IS NULL) "+
"CONNECT BY PARENT_GROUP_ID = PRIOR GROUP_ID",GROUP.class);
log4jLogger.info("query: "+query);
List<GROUP> groups = query.getResultList();
Result:Code:
INFO [http-8080-2] service.GroupAction (getGroups:36) - query: org.hibernate.ejb.QueryImpl@1a5db9c
...
Caused by: java.lang.NullPointerException
at org.hibernate.loader.DefaultEntityAliases.intern(DefaultEntityAliases.java:157)
at org.hibernate.loader.DefaultEntityAliases.getSuffixedPropertyAliases(DefaultEntityAliases.java:130)
at org.hibernate.loader.DefaultEntityAliases.<init>(DefaultEntityAliases.java:76)
at org.hibernate.loader.ColumnEntityAliases.<init>(ColumnEntityAliases.java:40)
at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:152)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:67)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:136)
at org.hibernate.impl.AbstractSessionImpl.getNativeSQLQueryPlan(AbstractSessionImpl.java:160)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
at test.GroupAction.getGroups(GroupAction.java:38)