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

primay key ???  RSS feed

 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should the primary key map to a column in the database?
What if my create method returns a value that is not the primary key of the entity bean?
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure I understand your question. Anyways let me try to explain. A findBy method in a Bean implementation returns the priamry key that is Present in the database and the ejbContainer will load the Entity Bean corresponding to the PrimaryKey and returns the EjbObject. If you try to find Data with the PrimaryKey that is not present in the database, I am not sure whether it will return a Null, or throw FinderException.
 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi shiva kumar,
What i wanted to know is if i return a junk value in my ejb create what is the consequence?
Hope i am clear
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What i wanted to know is if i return a junk value in my ejb create what is the consequence?
Hope i am clear

I am not that clear with your question. What you mean by you returning a junk value in the ejbCreate method ?!?!
Anyways, if you pass a junk PrimaryKey to the findByPrimaryKey method it will throw a sub-class of FinderException called "ObjectNotFoundException".
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!