This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes one to one mapping problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "one to one mapping problem" Watch "one to one mapping problem" New topic
Author

one to one mapping problem

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
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

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Jan 08, 2010
Posts: 510
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

Joined: Jan 08, 2010
Posts: 510
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

Joined: Jul 20, 2009
Posts: 188
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

Joined: Jan 08, 2010
Posts: 510
Thnks Christian Dillinger.
You are correct.
I missed that.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: one to one mapping problem
 
Similar Threads
Can't connect to MySQL database with Hibernate
Newbie got stuck in Hibernate "Hello World"
How to Set Primary / Foreign Keys or Relationships with Hibernate 3 / JPA Tables?
How to implement OneToOne entity without explicit id field
adding more than one entry