-->
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: problems with any-mapping property in where-clause
PostPosted: Wed Nov 10, 2004 5:29 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
Hibernate version:
2.1.6


How do I use a property that is "any-mapped" in a where-clause?

I keep getting this:
net.sf.hibernate.QueryException: path expression ends in a composite value: link0_.chained [from com.mds.pepland.persistence.Link link where link.chained=?]
at net.sf.hibernate.hql.PathExpressionParser.getWhereColumn(PathExpressionParser.java:375)
at net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:352)
at net.sf.hibernate.hql.WhereParser.doToken(WhereParser.java:366)
at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:251)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1517)
at com.mds.pepland.da.SearchDAO.deleteSearch(SearchDAO.java:85)

The query goes like this:
session.find("from Link link where link.chained=?", search, Hibernate.any(Hibernate.INTEGER, Hibernate.STRING));

The Link class has an any-mapping like this:
<any name="chained" id-type="java.lang.Integer" meta-type="string">
<meta-value value="Identification" class="com.mds.pepland.persistence.IdentificationImpl"/>
<meta-value value="FragmentIdentification" class="com.mds.pepland.persistence.FragmentIdentificationImpl"/>
<meta-value value="Search" class="com.mds.pepland.persistence.Search"/>
...
<column name="chained_table" length="32"/>
<column name="chained_id"/>
</any>

I've tried different variations for the type argument of session.find, but nothing seems to be working..

I'm suspecting that Hibernate does not support support this sort query, even though it seems natural to do it like this.. What are my options then? using a Hibernate SQL query?

regards...

_________________
Hibernate rocks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 10, 2004 5:46 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
Ok.. I found a solution.. the criteria API:

Criteria criteria = session.createCriteria(Link.class);
List l = criteria.add(Expression.eq("chained", search)).list();

does the trick..

regards...

_________________
Hibernate rocks!


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.