Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
With BMP it's possible because you write the JDBC code and decide the logic for storing the data.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
So, from my point of view, you can write entity bean to a table which does not have any Primary Key (whether it is CMP or BMP).
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Originally posted by Lasse Koskela:
Guru's reasoning sounds valid. What I'm not sure about it is whether there are any issues with having a "primary key constraint" in the EJB Container but not in the database. I guess it's possible that the EJB Container might check for a duplicate primary key before going to the database (which would prevent you from adding identical records into the table even though the data model allows it), but I really have no idea whether any implementation out there does this.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Originally posted by Ajay Hatkar:
If unique column contains null value ( it's unique right and only one record may have null value ), what primary key object container will return ?
Originally posted by Gurumurthy Ramamurthy:
It is not necessary that you should have a primary key for every table (technically). If you are embedding your JDBC code inside the entity bean, this is possible and you give the composite key (collection of more than one field) as the parameter to the PrimaryKey class. So, from my point of view, you can write entity bean to a table which does not have any Primary Key (whether it is CMP or BMP).
Guru
"When work, commitment and pleasure all become one and you reach that deep well where passion lives, nothing is impossible."
Don't get me started about those stupid light bulbs. |