Hi,
I have some problems when I use keyword VALUE() and KEY() in JPQL. When EntityManager generate SQL, it seems to do not transform keyword VALUE() and KEY().
I obtain exception :
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode \-[METHOD_CALL] MethodNode: '(' +-[METHOD_NAME] IdentNode: 'VALUE' {originalText=VALUE} \-[EXPR_LIST] SqlNode: 'exprList' \-[ALIAS_REF] IdentNode: 'elt2_.id' {alias=l, className=test.jpa2.entity.Elt, tableAlias=elt2_}
at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:154) at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:844) at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:632) at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:678) at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:294) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:237) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:98) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1760) at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:277) at test.jpa2.EmbededMapTest.dotest(EmbededMapTest.java:73)
my entities are :
@javax.persistence.Entity public class Entity implements Serializable { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String val;
@ManyToMany(cascade=CascadeType.ALL) private Map<String, Elt> elts =new HashMap<String, Elt>(); public Entity() ... public Long getId()... public void setId(Long id) ... public String getVal() ... public void setVal(String val) ... public Map<String, Elt> getElts() ... public void setElts(Map<String, Elt> elts) ... }
@Entity public class Elt implements Serializable { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String ssvalue;
public Elt()... public String getSsvalue()... public void setSsvalue(String ssvalue)... }
query : .... Query q = em.createQuery("select VALUE(l) from Entity e join e.elts l where KEY(l) = :name",Elt.class); q.setParameter("name", "e1"); List<Elt> l = q.getResultList(); ....
persitence.xml :
<persistence version="2.0" .....> <persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL"> <class>test.jpa2.entity.Entity</class> <class>test.jpa2.entity.Elt</class> <properties> <property name="hibernate.connection.driver_class" value="org.h2.Driver"/> <property name="hibernate.connection.username" value="sa"/> <property name="hibernate.connection.password" value=""/> <property name="hibernate.connection.url" value="jdbc:h2:file:./target/data/data"/> <property name="hibernate.max_fetch_depth" value="3"/> </properties> </persistence-unit> </persistence>
I use : H2 database hibernate-entitymanager 3.5.2 final
Could someone help me please ?
Thanks
|