• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Hibernate not inserting new record on SQL Server

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone

I have tried Hibernate in the past for a couple of pilot projects but I'm a total newbie. I am trying to do some basic testing/configuration for a new project I am working on. My configuration is:

MS SQL Server 2008 R2
Eclipse Helios (3.6.2)
Hibernate 3.6.4

I've created a simple table



a simple class



my hibernate.cfg.xml



and the company.hbm.xml mapping file



then I run this simple Java app to test it



I don't get any errors, and I can see the correct SQL statement in the console

Hibernate: insert into t_company_test (company_name) values (?)


but no records are inserted in the database. I did a debug with the profiler and found that it executes the following



Any ideas of what am I missing or doing wrong?

Thanks

Fernando Margueirat
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are not beginning a transaction.. After beginning, you need to commit also..
 
Fernando Margueirat
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank a lot for you quick reply. That was the problem. I guess the tutorial I was using was not very good.

Fernando Margueirat
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Watch out, there are a lot of very poor tutorials out there. Hibernate's documentation is a better source - it's example covers the need for a transaction.
 
Fernando Margueirat
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:Watch out, there are a lot of very poor tutorials out there. Hibernate's documentation is a better source - it's example covers the need for a transaction.



Thanks, I learned my lesson the hard way .

Fernando Margueirat
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic