• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Is primary key a must for an entity bean

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic