Is it possible to create CMP entity bean on a table that does not have primary key
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Prasoon_Choudhary
Posted On:   Sunday, January 27, 2002 10:26 PM

Is it possible to create CMP entity bean on a table that does not have primary key constrain defined at database level. But the table does have a candidate key which can be made primary key and I have not defined any constrain for that candidate key not even unique constrain. Assuming that I have created a primary key class based on the candidate key. 1)Now suppose two guys want to create an entity bean with same primary key will there be an exception. if yes which exception. 2) If there already exist a record in database with the same candidate key but now I want to create another enity bean with same primary key. what will happen. I think it should not give any problem as there is no primary key constrain at database le   More>>

Is it possible to create CMP entity bean on a table that does not have primary key constrain defined at database level. But the table does have a candidate key which can be made primary key and I have not defined any constrain for that candidate key not even unique constrain.


Assuming that I have created a primary key class based on the candidate key.

1)Now suppose two guys want to create an entity bean with same primary key will there be an exception. if yes which exception.

2) If there already exist a record in database with the same candidate key but now I want to create another enity bean with same primary key. what will happen. I think it should not give any problem as there is no primary key constrain at database level.

3)What will findbyprimarykey return when there are two records with same candidate key.



Please understand this is just a hypothetical situation I hope nobody has done this in their actual project :-)

   <<Less

Re: Is it possible to create CMP entity bean on a table that does not have primary key

Posted By:   AlessandroA_Garbagnati  
Posted On:   Monday, January 28, 2002 03:00 AM

Hi,

No, you cannot create a CMP without a primary key. The reason is simple: the Primary Key is used to uniquely identify your row. Without the Primary Key the database and the EJB container will not be able to return you the single row.


How would you identify the row if you do not have a primary key?

About | Sitemap | Contact