• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Data getting saved in session, but not being persisted in table.

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear dudes,
In persisting data in MySQL through hibernate, i'm using a simple java class , which creates an instance of my form , sets data , reads the configuration file, builds a session factory i.e. hibernate.cfg.xml , opens the session and save data .
Actually data was not inserted into the table eventhough i'm getting the message similar to that.

I created the database in MySQL initially.
message console:


My java application:"Testinghibernate.java"




Information.java


hibernate.cfg.xml:



Information.hbm.xml:
 
mara thamizhan
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
will someone please reply?
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Possible corrections you have to have work
1.If you are working in eclipse please check the application structure
2. remove the and run it.
 
jayachandra madopothula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

see the structure shown in the picture.

after arranging the whole structure just update resource mapping tag in hibernate.cfg.xml with absolute path of the hbm.xml
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hibernate requires a Transaction, and it to be commited to actually save stuff to the database. I do not see a

Transaction tx = session.beginTransaction();

and I also don't see a

tx.commit();

in your code.

Mark
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using Transaction it is working but Is this mandatory to use transaction in Hibernate ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic