• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Is primary key a must for an entity bean  RSS feed

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it mandatory to configure a primarykey in the deployment descriptor.

Not all the tables in the database contains a primarykey.

Suppose i have created an entity bean which represents a table that do not have a primary key.

Now my question is what can i put as a return type of 'ejbCreate' method in the above created entity bean & how do i configure the primarykey information in DeploymentDescriptor?
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why you have a table without pk?!
[ March 11, 2008: Message edited by: Elton Kuzniewski ]
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't sure, but why you don't need primary key?

How you find an entity without its identity? Or you don't want to find?
 
NareshAnkuskani Kumar
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

let me put the query in simple words.

Using entity beans is it possible to update or insert or delete a row in a database table which doesn't have a primary key?
 
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's possible. Which object will you be updating? What would be the differentiator for the object that you are updating to that of the other objects in the table?
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you referring to 2.x or 3.0 spec? EJB3 supports 2.x entity beans.

for JPA, refer to section 2.1.4 of the JSR220 persistence spec.

you must have a PK for an entity class in JPA.
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by NareshAnkuskani Kumar:
Thanks for your reply.

let me put the query in simple words.

Using entity beans is it possible to update or insert or delete a row in a database table which doesn't have a primary key?



A table doesn't need to have a primary key, but in most cases a table should have one. If we don't have a primary key, how can we identify data in the table? That's not good.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Bean Provider must specify the primary key class for an
entity bean with bean-managed persistence, and may (but is not required to) specify the primary key class for an entity bean with container-managed persistence.

For a CMP bean, the PK can be inferred from the findByPrimaryKey method.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!