Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3
Mapping documents:
<class name="Child" table="childtable">
<composite-id name="ParentId" class="ParentId" >
<key-property name="DbId" column="dbid" type="long"/>
<key-property name="UserId" column="userid" type="UserIdUserType" />
</composite-id>
<map name="Attributes" lazy="false" table="ChildAttribute" cascade="all" >
<key>
<column name="DbId" not-null="true"/>
<column name="profileid" not-null="true"/>
</key>
<map-key type="string" column="attribute_name" />
<element type="string" column="attribute_value"/>
</map>
</class>
Code between sessionFactory.openSession() and session.close():
I need to query from the map of child attributes. I need to update the attribute values for all those rows where DbId in a particular set of numbers and the attribute name has a specific value.
in sql, would be something like,
update childattribute
set attribute_value = "newValue"
where attribute_name = "attrbute1"
and dbid in (1,2,3,4,5)
The query that I used is as follows.
update ChildAttribute
set Attributes[?] = ?
where ? in indices(Child.Attributes)
and id.DbId in (?, ?)
Full stack trace of any exception that occurs:
org.hibernate.hql.ast.QuerySyntaxError: expecting EQ, found '[' near line 1, column 48 [
update ChildAttribute set Attributes[?] = ?
where ? in indices(Child.Attributes) and id.DbId in (?, ?)]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:215)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
I tried to find out what the exception meant exactly, but was unable to find anything either in the documentation or HIA. If someone could help me, it would be great. Also, if someone could give some information on using HQL with collection objects,it would be great.
Name and version of the database you are using:
oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: