-->
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: hibernate does not save
PostPosted: Mon May 14, 2007 3:51 pm 
Beginner
Beginner

Joined: Thu Jan 20, 2005 1:45 pm
Posts: 49
Hi all
I created a DAO with my eclipse and one mapping file on my silly table.
I created a test app that try to save a pojo object in the database.
Enabling log4j it says "save successful" but when i check the databse there is nothing in the table.
That's my dao code:

...
public void save(Dates transientInstance) {
log.debug("saving Dates instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
...

and my cfg :
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>

<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost/agenda
</property>
<property name="connection.username">root</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">
agendaProfile
</property>
<property name="connection.password">admin</property>
<property name="connection.autocommit">true</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="transaction.flush_before_completion">
true
</property>
<property name="transaction.flush_before_completion">
true
</property>
<mapping resource="Dates.hbm.xml" />
<mapping resource="Profiles.hbm.xml" />

</session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject: hibernate does not save
PostPosted: Mon May 14, 2007 5:48 pm 
Beginner
Beginner

Joined: Wed Apr 18, 2007 6:17 pm
Posts: 49
Location: Dominican Republic
you can try creating a transaction and then commit it.

If it help please rate the post...


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 9:50 am 
Newbie

Joined: Mon May 21, 2007 10:54 am
Posts: 2
Solution: add/set ur hibernate.cfg.xml
with : <property name="connection.autocommit">true</property>

I recomand you first to read this:
http://www.hibernate.org/403.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 9:57 am 
Newbie

Joined: Thu May 17, 2007 11:27 am
Posts: 8
Location: US
In program you can do the following
session.beginTransaction();
session.save(object);
session.getTransaction().commit();

_________________
Raemond


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.