• Post Reply Bookmark Topic Watch Topic
  • New Topic

what happen when a table haven't Primary Key?

 
Along huang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
As EJB's specifiction described, all Entity Bean must have a primary key to uniquely identify a data row in database, but facing a table wihtout primary key, how do entity bean identify the data from database? and how do i deploy the prim-key-class attrubite of the XML description file?

thanks in advanced,
Along
 
Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entity Bean should have a primary key. Even if your table does not have primary key, it does not matter. What happens in this case is that it will retrieve more than one records which satisfy the key.

The prim-key-class can be either the wrappers to primitive or your own Primary Key class.

Thanks,
Guru
 
Along huang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since it haven't primary key, of course I don't know what data type it is,
so, it is impossible to fill out the prim-key-class.

How can I do?
thanks
 
Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB2.0 defers primary key till the deployment time.
So, if you don't know the type, still you can declare as java.lang.Object as prim-key-class.

thanks,
Guru
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!