• Post Reply Bookmark Topic Watch Topic
  • New Topic

CMP with out key field in table

 
Sudhakar Rao
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it possible to create CMP with no primary key column in the database table.
Thanks in Advance
Sudhakar
 
Chris Brat
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Nope - you need to have a primary key field in the table which must link with the virtual primary key field in the bean and its DD.

The container uses this information to check for equality (entity beans represent the same entity if the primary key is the same) and also to find the entity since all entity beans must at least have the findByPrimaryKey(Object) method.

What type of operation are you trying to perform?

Chris
 
Chris Brat
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooops, almost forgot that you can have a composite key.

If you use a composite key (combination of two or more fields in the table) represented by a primary key class then you dont need to have primary key in the table - though I dont recommend that you never use primary keys in tables.

An example of this type of composite key could be a persons ID number and name.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!