Here you go...

jabber (jabber)
Whether you use single-fielded or multi-fielded primary key id determined by your business data.

Wrapper classes (Integer, Boolean...) cannot be used as primary key because their sole instance variable is PRIVATE. (Wrapper classes follow the immutable pattern.) The instance variables of a primary key must be PUBLIC so that the EJB container can access them directly.
To say, you have a primary class as follows:

public class PK implements java.io.Serializable{

public PK(id) {
public int id;

You should be abale to write the following code:

PK pk= new PK(4);

Note the syntax above that directly accesses id.
2001-3-11 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: EJB. What's the difference between compound primary key and single-field key? Why cannot the primary keys be primitive types in single-field key? I read some books but can't get the answer. thank you!

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论