-->
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: Database(MYSQL) is not updated
PostPosted: Fri Mar 28, 2008 2:09 am 
Newbie

Joined: Fri Mar 28, 2008 1:59 am
Posts: 1
Hi,
I am just novice to Hibernate.I am doing very simple example.Everything is working fine but database is not updated.I am just inserting records in the table.
java Bean file:Contact.java

Hibernate version:3.2

Mapping documents<?xml version="1.0"?>
<!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.oreilly.Contact" table="CONTACT">
<id name="id" type="integ" column="ID" >
<generator class="assigned"/>
</id>

<property name="firstName">
<column name="FIRSTNAME" />
</property>
<property name="lastName">
<column name="LASTNAME"/>
</property>
<property name="email">
<column name="EMAIL"/>
</property>
</class>
</hibernate-mapping>

:



Code between sessionFactory.openSession() and session.close()
Contact contact = new Contact();
contact.setId(3);
contact.setFirstName("Pranabesh");
contact.setLastName("Paul");
contact.setEmail("pranabesh.paul@wipro.com");
session.save(contact);
System.out.println("Done");
}catch(Exception e){
System.out.println("Exception is here"+e.getMessage());
}finally{
// Actual contact insertion will happen at this step
session.flush();
session.close();
System.out.println("Its over");
}
:

Full stack trace of any exception that occursNo Exception
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Inserting Record
Done
Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?)
Its over
:


Name and version of the database you are using:
MYSQL 5.0


The generated SQL (show_sql=true):
yes
Debug level Hibernate log excerpt:
i have not set yet


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 6:34 am 
Regular
Regular

Joined: Mon Aug 06, 2007 10:49 am
Posts: 67
Location: Banska Bystrica, Slovakia
try use transaction

http://www.hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 4:56 pm 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
post ur hibernate.cfg.xml file...

Check to see..if your cf.xml is as below...
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/DBName</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">******</property>

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


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.