-->
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.  [ 7 posts ] 
Author Message
 Post subject: Is string a valid type for id?
PostPosted: Mon Jan 10, 2005 3:08 am 
Beginner
Beginner

Joined: Sun Jan 09, 2005 5:16 pm
Posts: 20
My code works fine if I use a long, but I'm getting this with a string:

ERROR - SessionImpl.execute(2379) | Could not synchronize database state with session
net.sf.hibernate.HibernateException: Batch update row count wrong: 0

here's my mapping for it:

<id name="id" type="string" column="USER_ID" unsaved-value="null">
<generator class="assigned"/>
</id>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 3:28 am 
Beginner
Beginner

Joined: Sun Jan 09, 2005 5:16 pm
Posts: 20
I was able to get the insert to work by changing from saveOrUpdate() to just save(). Could somebody shed some light on this? I'd rather not have to write the code to check if the entry exists and then explicity call update.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 6:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
saveOrUpdate() in 2.1.7 won't work with generator=assigned, because there is no way for Hibernate to figure out if the object is unsaved or not.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 6:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it should be able to work if you have implemented Interceptor.isUnsaved()

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 6:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
...and is called Interceptor.isTransient() in H3

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 3:15 pm 
Beginner
Beginner

Joined: Sun Jan 09, 2005 5:16 pm
Posts: 20
thanks for the response. I'm using 2.1.6 and spring 1.1.3, but I'm not quite sure how to implement isUnsaved().

This isn't working unfortunately. Do I do a select in isUnsaved and return false if the entry was found?

Interceptor e = getHibernateTemplate().getEntityInterceptor();
e.isUnsaved(getHibernateTemplate().saveOrUpdate(user));


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 6:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
If you want to do a select before update, use select-before-update=true


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.