-->
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: I saved an object but I can't see the changes in the db
PostPosted: Sun Aug 08, 2004 7:04 am 
Newbie

Joined: Tue Mar 16, 2004 7:14 am
Posts: 3
Location: Aachen, Germany
Hi there,

I know this topic is in the FAQ, but I still can't figure out what I am missing. If I want to do anything with the DB I seem to have to use a Transaction around the code. If I don't do it, no data is saved in the DB.

TIA chris

Hibernate version: 2.1.2

Mapping documents:
Code:
<hibernate-mapping package="com.schluer.schluerdb.model">

   <class name="LeadPerson" table="LeadPerson">
      <id name="id" type="long">
         <generator class="native"/>
      </id>
      <many-to-one name="department"/>
      <many-to-one name="rank"/>
      <many-to-one name="sex"/>
      <property name="title" type="string"/>   
      <property name="forename" type="string"/>
      <property name="surename" type="string"/>
      <set name="contactData" cascade="delete">
         <key column="leadPersonID"/>
         <one-to-many class="Contact"/>
      </set>   
      <set name="acceptedNewsletters" cascade="delete">
         <key column="leadPersonId"/>
         <many-to-many column="newsletterId" class="Newsletter"/>
      </set>
   </class>
   
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
Session sess = HibernateUtil.currentSession();      
LeadPerson p = new LeadPerson();
p.setSurename("Tester");
p.setForename("Test");
sess.save(p);
sess.flush();
HibernateUtil.closeSession();


Full stack trace of any exception that occurs: none

Name and version of the database you are using: PostgreSQL 7.4.1 with JDBC3 driver.

Debug level Hibernate log excerpt:
Code:
12:51:14,951  INFO QueryCache:39 - starting query cache at region: net.sf.hibernate.cache.QueryCache
12:51:15,072 DEBUG SQL:237 - select nextval ('hibernate_sequence')
12:51:15,122 DEBUG SQL:237 - insert into LeadPerson (department, rank, sex, title, forename, surename, id) values (?, ?, ?, ?, ?, ?, ?)
12:51:15,132 DEBUG LongType:41 - binding null to parameter: 1
12:51:15,132 DEBUG LongType:41 - binding null to parameter: 2
12:51:15,132 DEBUG LongType:41 - binding null to parameter: 3
12:51:15,142 DEBUG StringType:41 - binding null to parameter: 4
12:51:15,142 DEBUG StringType:46 - binding 'Test' to parameter: 5
12:51:15,142 DEBUG StringType:46 - binding 'Tester' to parameter: 6
12:51:15,152 DEBUG LongType:46 - binding '152' to parameter: 7


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 10:18 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Quote:
If I want to do anything with the DB I seem to have to use a Transaction around the code. If I don't do it, no data is saved in the DB.


Is this a trick question? Of course you have to use transactions.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.