Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one to one mapping problem

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my exam class


here is me examDetail class



here is error i am getting


 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error is happening at this line:

transaction.commit();

It might even appear that it is a problem getting the actual connection. I see a JNDI lookup there. Perhaps either the connection pool is not being obtained by the JNDI lookup, or if you've configured transactions through JNDI, the JNDI lookup on the UserTransaction object is failing.

For some reason your transaction is not committing. That's the key. Do you have any idea why that line of code might be failing?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put session.save(detail); above the session.save(exam);.

now it seems llike this


then it gives this error

anyway nullpointer means it doesn't make session?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can't be JNDI problem
i am using same connection to run this example too.Still it runs well




here is my config file


Both of these examples are in same project.So they use same database connection and same schema.
But different tables
 
Christian Dillinger
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if you changed your original sample, but here you never set transaction. So it's okay that you get a NPE.



In your last post you had "transaction = session.beginTransaction()".
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnks Christian Dillinger.
You are correct.
I missed that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic