-->
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.  [ 3 posts ] 
Author Message
 Post subject: problem with spring and hibernate getHibernateTemplate.save
PostPosted: Fri Feb 10, 2006 5:42 am 
Newbie

Joined: Fri Feb 10, 2006 5:26 am
Posts: 2
I meet a strange problem with spring and hibernate.
I am developing a forum. With a thread there are many thread bodies. Any thread body has a foreign key to a thread.
When I call getHibernateTemplate().save(thread) method, there is no any exceptions and the SQL is shown normally. Then I checked the thread object and found that the ID is set with a uuid. In the same session I saved a thread body with that thread and there is no exception too. BUT there is nothing saved into database.
I use OpenSessionInView and org.springframework.transaction.interceptor.TransactionProxyFactoryBean to provide a writable session.
There is no problem with any other table, and this problem happens sometime. About a half of threads can't be written into database, and the others is correct.

Thank you very much!

Hibernate version:
3.0.5
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.lintun.bbs.domain.Thread" table="thread">

<id column="id" name="id" length="32" type="java.lang.String">
<generator class="uuid.hex"/>
</id>


<property column="topic" length="100" name="topic" not-null="true" type="java.lang.String"/>
<many-to-one column="poster" name="poster" class="com.lintun.bbs.domain.User"/>
<property column="start_time" name="startTime" not-null="true" type="java.util.Calendar"/>
<property column="post_time" name="postTime" not-null="true" type="java.util.Calendar"/>
<many-to-one column="last_replier" name="lastReplier" class="com.lintun.bbs.domain.User"/>
<property column="is_prime" name="isPrime" not-null="true" type="java.lang.Boolean"/>
<property column="is_top" name="isTop" not-null="true" type="java.lang.Boolean"/>
<property column="reply_count" name="replyCount" not-null="true" type="java.lang.Integer"/>
<property column="click_count" name="clickCount" not-null="true" type="java.lang.Integer"/>
<property column="reply_count_today" name="replyCountToday" not-null="true" type="java.lang.Integer"/>
<property column="click_count_today" name="clickCountToday" not-null="true" type="java.lang.Integer"/>
<many-to-one column="board" name="board" class="com.lintun.bbs.domain.Board"/>
<many-to-one column="section" name="section" class="com.lintun.bbs.domain.Section"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
getHibernateTemplate().save(thread);
Full stack trace of any exception that occurs:
No any exception
Name and version of the database you are using:
Postgresql 8.1.1
The generated SQL (show_sql=true):
Hibernate: insert into thread (topic, poster, start_time, post_time, last_replier, is_prime, is_top, reply_count, click_count, reply_count_today, click_count_today, board, section, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:
N/A


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 7:02 am 
Beginner
Beginner

Joined: Mon Dec 05, 2005 4:15 am
Posts: 36
Did you commit the transaction?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 7:15 am 
Newbie

Joined: Fri Feb 10, 2006 5:26 am
Posts: 2
I have traced the code.
When it runs correctly, I can see the new record with pgAdmin.
So I am sure that the session is flushed immediatly.


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