This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

UserTransaction question  RSS feed

 
Joe Joseph
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for asking this relatively dumb question, the answer for which i could have figured out myself. MY RAD has crashed & hence i am unable to test.

What would happen if i do the below in a BMT:
UserTransaction objUserTansaction = null;
objUserTansaction.commit();

In this case will i get a NullPointerException or an IllegalStateException???
I was expecting a NullPointerException.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37230
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,
You'll definitely get a null pointer. This is due to Java. Since commit is not a static method, it gets called on the object. Which is null.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!