I work on a project and we use Enterprise Java Beans with MySql database The problem is that one table has two primary Keys but in the entity Beans only one primary Key class can be implemented. How to solve the problem if there are more than one primary key
thank you for your support
Joined: Mar 28, 2005
You have to create a primary key class to wrap the two primary keys into this primary key class. Lookup the topic complex primary key on EJB, I bet you can find more information on this.
Originally posted by holger Hahn: The problem is that one table has two primary Keys but in the entity Beans only one primary Key class can be implemented.
First let's clarify what this means. If it means a primary key with two fields, you can do what Jeremy suggested. Taken literally, it sounds like you have two primary keys, either of which is unique. This isn't supported by most databases and cannot be done in EJB. Instead, you implement a unique constraint in the database for the second "primary key."