-->
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: Assigning to components using an Update statement
PostPosted: Thu May 03, 2007 8:41 pm 
Newbie

Joined: Tue Feb 27, 2007 12:31 pm
Posts: 8
Location: nyc
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1.0

Mapping documents:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class table="Investor" name="com.fds.white.Investor">
<id access="property" unsaved-value="-1" name="id">
<generator class="native"/>
</id>
<property name="address1" access="property"/>
<property name="address2" access="property"/>
<property name="address3" access="property"/>
<property name="city" access="property"/>
<property name="state" access="property"/>
<property name="email" access="property"/>
<property name="fax" access="property"/>
<property name="name" access="property"/>
<property name="tel" access="property"/>
<property name="zip" access="property"/>
<property name="title" access="property"/>
<property name="voided" access="property"/>
<component name="thing" access="property">
<property name="strNumber" column="jeffAmt" access="property"/>
</component>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Session sess = getSession();
log.debug("UPDATE Investor SET thing=? WHERE id=?");
Query q = sess.createQuery("UPDATE Investor SET thing=? WHERE id=?");
if(arg1!=null)
q.setParameter(0, arg1);
if(arg2!=null)
q.setParameter(1, arg2);
q.executeUpdate();
releaseSession(sess);

Full stack trace of any exception that occurs:
org.hibernate.QueryException: Components currently not assignable in update statements [UPDATE com.fds.white.Fund SET authShareOrCapital=? WHERE id=?]
at org.hibernate.hql.ast.tree.AssignmentSpecification.validateLhs(AssignmentSpecification.java:132)
at org.hibernate.hql.ast.tree.AssignmentSpecification.<init>(AssignmentSpecification.java:52)
at org.hibernate.hql.ast.HqlSqlWalker.evaluateAssignment(HqlSqlWalker.java:848)
at org.hibernate.hql.ast.HqlSqlWalker.evaluateAssignment(HqlSqlWalker.java:842)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.assignment(HqlSqlBaseWalker.java:1022)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.setClause(HqlSqlBaseWalker.java:727)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.updateStatement(HqlSqlBaseWalker.java:347)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:235)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:74)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:53)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1540)
at com.fds.hibernate.HibernateDAOManager.update(HibernateDAOManager.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:165)
at $Proxy1.update(Unknown Source)
at Jeff.testUpdate(Jeff.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Does anyone know if this type of update to a property configured as a component is allowed with a later version of hibernate?

It actually seems that it is allowed on any class that is not either: abstract, joined-subclass, or has some other class in the model that extends it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 1:07 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
It works with hibernate-3.2.3
I tried it out.
But, I don't know from which version it is supported.

--------------------------------------------------
Rate the reply if you find it helpful


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.