File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Pimary keys in entity beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Pimary keys in entity beans" Watch "Pimary keys in entity beans" New topic

Pimary keys in entity beans

shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
when is a duplicate primary key exception thrown?
Can 2 entity bean instances access the same primary key.If not why?
Can different instances of the same entity bean access the same primary key?
Bit confused regarding this please explain
Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
Well, an exception is thrown when trying to insert a record inside the database and there already is a record with that primary key.
2 entity beans will access the same primary key in a clustered environment. Inside a single application server there will not be two beans representing the same record, though this might depend on the applications server. I'm walking the path...
shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
could u pls explainur reply in detail as to why in a clustered envo the same data can be accessed and y does it depend on app servers as to the data being accessed is same or not
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Is DuplicateKeyException thrown even when there are no database constraints on the table. Say there is a primary key for a table, but has no unique constraint.....
I agree. Here's the link:
subject: Pimary keys in entity beans
It's not a secret anymore!