Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Object Relational Mapping
hibernate basic Program
vendikonda sravan
Ranch Hand
Posts: 38
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi ,
i wrote a simple hibernate Program got no exceptions but i'm still not able to see the database updated.
what might possible be wronge please help
.
Thanks
sravan V
Paul Sturrock
Bartender
Posts: 10336
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Did you commit your transaction?
JavaRanch FAQ
HowToAskQuestionsOnJavaRanch
vendikonda sravan
Ranch Hand
Posts: 38
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
yes i have here is the code
package com.Project; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.Transaction; import com.Project.EmployeePojo; import com.Project.HibernateSessionFactory; public class HibernateMain { public static void main(String[] args) { // TODO Auto-generated method stub Session session =null ; Transaction transaction = null; try{ // This step will read hibernate.cfg.xml SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session =sessionFactory.openSession(); /* Configuration cfg = new Configuration() .addResource("connect.hbm.xml");*/ //session = HibernateSessionFactory.getSession() ; transaction = session.beginTransaction(); EmployeePojo emp = new EmployeePojo(); emp.setEid(3); emp.setEMobile("9966836508"); emp.setEname("sravan"); emp.setESalary("1000"); emp.setEEmail("abc@xyz"); transaction.commit(); }catch(Exception e){ System.out.println(e.getMessage()); }finally{ // Actual contact insertion will happen at this step session.flush(); HibernateSessionFactory.closeSession(); } } }
Ares Fergusson
Greenhorn
Posts: 1
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Try first:
session.save(emp);
just before commiting the transaction(after line 31). I think it will work, if you've done your mappings right.
Varun Phadnis
Greenhorn
Posts: 4
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If you are setting hbm2ddl property then try setting it to "update"
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Retrieving Data from database and showing through Servlets
employee database system using Java technoloyges
Hibernate basic
float error
Need ideas ......or hints...
More...