-->
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: Does hibernate support user defined types in bulk update que
PostPosted: Mon Aug 01, 2005 11:27 pm 
Newbie

Joined: Mon Aug 01, 2005 11:16 pm
Posts: 1
Does hibernate support user defined types in bulk update query? Or i do someth wrong?

Hibernate version:
3.0.5

Mapping documents:
Code:
<hibernate-mapping>

   <class
      name="de.***.bbs.model.Order"
      table="BBS_ORDER">
      <id
         access="field"
         column="BBS_ORDER_ID"
         length="10"
         name="orderId"
         type="string">
         <generator class="assigned" />
      </id>
      <version
         name="lastModificationDate"
         column="BBS_ORDER_LAST_MODIFICATION_DATE"
         type="timestamp" />
      <many-to-one
         name="client"
         cascade="save-update"
         column="BBS_ORDER_CLIENT_ID"
         lazy="true"
         not-null="true"
         access="field"
         class="de.***.bbs.model.Client"
         foreign-key="FK__ORDER_CLIENT" />

      <property
         name="status"
         column="BBS_ORDER_STATUS"
         not-null="true"
         type="de.***.bbs.model.hbm.types.OrderStatusType"
         length="15" />
   </class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
Transaction tx = getSession().beginTransaction();
        String q = "update de.***.bbs.model.Order set status = :status where client = :c";
        getSession().createQuery(q).setParameter("status", OrderStatus.incasso).setParameter("c", c).executeUpdate();
        tx.commit();

Full stack trace of any exception that occurs:
Code:
org.hibernate.HibernateException: Could not determine a type for class: de.***.bbs.model.OrderStatus
   at org.hibernate.impl.AbstractQueryImpl.guessType(AbstractQueryImpl.java:471)
   at org.hibernate.impl.AbstractQueryImpl.guessType(AbstractQueryImpl.java:455)
   at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:448)
   at de.***.bbs.ui.actions.folders.MoveToInkassoUpdate.testBulkUpdate(MoveToInkassoUpdate.java:24)
   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)
   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.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



Name and version of the database you are using:
MySql 4.1 stream


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 3:46 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

we use a similar update query with usertypes.

You have to do something like this:
Code:
String q = "update com.ifbag.okular.base.hibernate.tst.User set lastLogon = :lastLogon";
session.createQuery(q).setParameter("lastLogon", new Date(), Hibernate.custom(DateType.class)).executeUpdate();
tx.commit();


And our type-class (i.e. not the usertype class)
is serializabe.


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.