-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JPA2 : Pb with JPQL Map and VALUE() and KEY()
PostPosted: Wed May 26, 2010 3:41 am 
Newbie

Joined: Tue May 25, 2010 11:44 am
Posts: 1
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


Top
 Profile  
 
 Post subject: Re: JPA2 : Pb with JPQL Map and VALUE() and KEY()
PostPosted: Sun Apr 10, 2011 3:25 am 
Newbie

Joined: Thu Feb 21, 2008 12:15 pm
Posts: 4
I am having the exact same issue


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.