Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Insert - help

 
G.Sathish kumar
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used hibernate for one of my project in my old company without association

i heared about auto generation tools there in the eclipse so i try to generate the mappling and do code but in the final when i try to the both table it is not working
here i added the codes i am using

please check and let me know if i am wrong anywhere
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

it is not working

It's hard to help without knowing a bit more. What is not working? How is it not working? Is there any error message? If not, how is it behaving differently from what you expect?
 
G.Sathish kumar
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:

it is not working

It's hard to help without knowing a bit more. What is not working? How is it not working? Is there any error message? If not, how is it behaving differently from what you expect?


when i try to insert the new object for bank with the pull of one user object is not getting saved in the database.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you commit your transaction?
 
G.Sathish kumar
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:Where do you commit your transaction?
i am not using transaction

on save i am calling getSession().save(p1); p1 is the object of bank and i try to see in the db end but i am not able to see it saved
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using a database you are always using a transaction. In order to use Hibernate without explicitly declaring a transation you will need to make the session auto-commit.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:In order to use Hibernate without explicitly declaring a transation you will need to make the session auto-commit.


Or if you use EJBs, enable CMT.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic