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 ?