1) Is it required to have a create method in the Home interface of the Entity Bean?
Beacuse i created a Employee Bean with no create in the Home interface and no ejbCreate in the Bean Class. When i varified it using the Deploytool, it gave me error saying required a ejbCreate in the Bean class. I will again try this and post the code for Component, Home and Bean class later.
I have Employee table in oracle database. The primary Key is Empno NUMBER(4). Now when i create a Entity Bean the deploytool of J2ee RE 1.3, somewhere asks for the primary key class. As specified in the Head First Book the primary key class can only be String or wrapper classes, how can i define a ejbCreate method for this Bean?
Can i define it like this --
public int ejbCreate() or should it be defined as public Integer ejbCreate()
How should the findByPrimaryKey method for this be defined in the Home interface??
Can it be like this public Employee findByPrimaryKey(int empno) or should it be public Employee findByPrimaryKey(Integer empno)
4) What i am trying to understand in questions 2 and 3 is, can we use primitive data type for the primary key of a Entity Bean?
Is it required to have a create method in the Home interface of the Entity Bean?
No, it isn't.
2, 3 and 4) You cannot use a primitive type for your primary key when using entity beans. At least not if you want to follow the specs. Your PK class must be a java.lang.Object according to the specs. There are ejb containers that allow you to use primitive types for a PK, but using this 'feature' blocks portability... [ August 09, 2004: Message edited by: Jef Cumps ]
Your PK class must be a java.lang.Object according to the specs.
Just to clarify: your primary key class could be any class provided that it's a valid RMI-IIOP type, and that implements the hashCode and equals methods and that defines each instance field as public and that it defines an empty constructor and that each field declared in it it's defined as a virtual persistent field in the entity bean class (and that the entity bean class has got getters methods for it. (Specs 10.6.13, 10.8.2)
Because any class inherits from java.lang.Object, inherently any primary key class is a java.lang.Object type.
Marco Tedone<br />SCJP1.4,SCJP5,SCBCD,SCWCD
Why fit in when you were born to stand out? - Seuss. Tiny ad: