-->
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.  [ 4 posts ] 
Author Message
 Post subject: Can't call commit when autocommit=true ?!!
PostPosted: Sat Nov 06, 2004 10:22 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
2.1.6:

<hibernate-mapping package="lyo.hotmail.site.bean">
<class name="Article" table="article">
<id
column="ARTICLE_ID"
name="Id"
type="long"
>
<generator class="hilo" />
</id>
<!-- please tell Joe Hudson that the type 'longblob' could not be resolved.. defaulting to java.lang.String -->
<property
column="ARTICLE_ICON"
name="ArticleIcon"
not-null="false"
type="java.lang.String"
/>
<property
column="ARTICLE_TITLE"
length="50"
name="ArticleTitle"
not-null="false"
type="string"
/>
<property
column="ARTICLE_TIME"
length="10"
name="ArticleTime"
not-null="false"
type="date"
/>
<property
column="ARTICLE_CONTENT"

name="ArticleContent"
not-null="false"
type="string"
/>

<many-to-one
class="User"
name="User"
not-null="true"
>
<column name="USER_ID" />
</many-to-one>
<many-to-one
class="Article"
name="ArtArticle"
not-null="true"
>
<column name="ART_ARTICLE_ID" />
</many-to-one>
<many-to-one
class="Forum"
name="Forum"
not-null="true"
>
<column name="FORUM_ID" />
</many-to-one>
<set
inverse="true"
lazy="true"
name="ArticleSet"
>
<key column="ART_ARTICLE_ID" />
<one-to-many class="Article" />
</set>
</class>
</hibernate-mapping>:


return (String)this.getHibernateTemplate().save(o);

org.springframework.jdbc.UncategorizedSQLException: (Hibernate operation): encountered SQLException [Can't call commit when autocommit=true]; nested exception is java.sql.SQLException: Can't call commit when autocommit=true
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:94)
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:281)
org.springframework.orm.hibernate.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:249)
org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:231)
org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:181)
org.springframework.orm.hibernate.HibernateTemplate.save(HibernateTemplate.java:298)
lyo.hotmail.site.service.ForumDAOImpl.insertObject(ForumDAOImpl.java:57)
lyo.hotmail.site.action.PostArticleController.handleRequest(PostArticleController.java:57)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:495)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:321)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
:


MySQL 4.0.13:

The generated SQL (show_sql=true):

INFO:

I use Hibernate with Spring . My code is simple:
Code:
public String insertObject(Object o){
       //don't work why? :(
   
       return (String)this.getHibernateTemplate().save(o);
}


When I insert data use this method,Tomcat report this error. Why?
Some one come across this problem ?

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 07, 2004 4:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Put your JDBC driver to autocommit=false.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: :(
PostPosted: Sun Nov 07, 2004 11:14 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
emmanuel wrote:
Put your JDBC driver to autocommit=false.


Thks emmanuel:

But where do I set the value ? Which config file should I change?

I couldn't find the "autocommit " option in the hibernate.properties.

help

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:46 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Actually when calling session.begin(), hibernate set autocommit to false.
Or use hibernate.connection.autocommit

_________________
Emmanuel


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