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{

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 -05:00

回到话题: 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!

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论