Hi, I know this problem is not new at all, but after a good search throughout the forum, I have no found evidence of how the current state of querying composite-elements is. The most important threads I've found about this are:
http://forum.hibernate.org/viewtopic.ph ... ent+filter
and
http://forum.hibernate.org/viewtopic.ph ... ent+filter
However, I still wonder if it is possible to query this type of objects by means of createFilter( Object colleciton, String query ).
I my case I have users who have attributes both connected together by a user_attribute_value composite-element in the user side. So when I do:
Code:
user.getUserAttributeValues()
I get a Set of UserAttributeValue objects.
However, If I try something like that:
Code:
List ls = dataManager.getSession().createFilter( user.getUserAttributeValues(),
"where this.userAttribute.name = ?" ).
setString( 0, "UserAttribute0" ).list();
it is doomed to failure... :(
Code:
org.hibernate.QueryException: collection of values in filter: this [where this.userAttribute.name = ?]
at org.hibernate.hql.ast.HqlSqlWalker.prepareFromClauseInputTree(HqlSqlWalker.java:154)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:497)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:371)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:98)
at org.hibernate.impl.SessionFactoryImpl.getFilter(SessionFactoryImpl.java:453)
at org.hibernate.impl.SessionImpl.getFilterTranslator(SessionImpl.java:1183)
at org.hibernate.impl.SessionImpl.listFilter(SessionImpl.java:1209)
at org.hibernate.impl.CollectionFilterImpl.list(CollectionFilterImpl.java:46)
at com.fresh.uvs.entity.test.core.UserTest.runAdditionalTests(UserTest.java:267)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
Do I have to turn my composite-element classes into entity classes if I want to do queries like the previous one??
Thanks a lot for your help.