-->
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: session.update with PostgreSQL fails
PostPosted: Fri Jun 20, 2008 6:37 am 
Newbie

Joined: Fri Jun 20, 2008 6:23 am
Posts: 6
I'm running Spring with Hibernate (3.2.5) and PostgreSQL (8.3).
And when I try to do session.update(myobject) I get the following error:

Code:
HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.Exception: Controller: UserController threw exception: Could not execute JDBC batch update

root cause

java.lang.Exception: Controller: UserController threw exception: Could not execute JDBC batch update

root cause

org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

root cause

java.sql.BatchUpdateException: Batch entry 0 update public.portaluser set email=matjaz.muhic@tridens.si, name=changethis, surname=changethis, username=matjaz, password=123123123123, confirmid=confirmed, age=0, sex=changethis, country=changethis, city=changethis, photourl=changethis, phonetype=changethis, dateofbirth=NULL, blocked=no, lastlogin=NULL, phonenum=0 where portaluserid=13213216513535 was aborted.  Call getNextException to see the cause.

note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_02 logs.
Sun Java System Application Server 9.1_02


Then I thought it was problem cause dateobirth and lastlogin are NULL. But I tried executing query in pgAdmin (with and without those parameters being NULL) and I get the following error:

Code:
ERROR:  missing FROM-clause entry for table "matjaz"
LINE 1: update public.portaluser set email=matjaz.muhic@tridens.si, ...
                                           ^

********** Error **********

ERROR: missing FROM-clause entry for table "matjaz"
SQL state: 42P01
Character: 36


Any suggestions? Or should I just forget it and write my own SQL update query?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 10:01 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
What is the full HQL for the update you are executing.

Here's a working HQL that does a batch update on your system. Are you following a similar syntax?

Code:
Session session = HibernateUtil.beginTransaction();
String hql = "update User
                set password = 'abc123'
                  where password='password')";
Query query = session.createQuery(hql);
int rowCount = query.executeUpdate();
System.out.println(rowCount + " rows were updated.");
HibernateUtil.commitTransaction();

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.