Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes can setter methods exist for primary key? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "can setter methods exist for primary key?" Watch "can setter methods exist for primary key?" New topic
Author

can setter methods exist for primary key?

trivikram Kumar
Ranch Hand

Joined: Feb 21, 2005
Posts: 172
If the answer is no then the sentence:

Setter methods for fields associated with the primary key must not be associated through a client view is correct or wrong??

I am confused after seeeing this as termed correct in HFEJB final mock (46th question).
Could someone please explain this....


Javainn<br /> <br />SCJP,SCWCD,SCBCD,<br />ICED (IBM-287,IBM-484,IBM-486)
IBM certified in DB2 V 8.1 Family Fundamentals (IBM 700)
KasiMurugan Ramasamy
Ranch Hand

Joined: Jan 30, 2005
Posts: 125
S javainn

If you provide the setter methods in client view, assume the client trying to change the primary key means, for the updation purpose( i mean Bean to DB) the container couldn't find the primary for the bean, it resultant that a container would throw an exception.

So the conclusion is you can keep the setter methods in client view, it never disturb compilation and deployment process, but it would throw an exception while you calling in the client view.

So never disclosure your primary key fileds setter methods. It is not encouraged. Thats all.

I feel, you will get me.


Thanks & Regards
Kasimurugan (SCJP1.4, SCBCD1.3), Preparing SCWCD1.4
chao cai
Ranch Hand

Joined: May 26, 2005
Posts: 154
yes,
like the ejbCreate must return null,not need to return the primary key.
container will set the primary key


SCEA<br />SCJP 1.2<br />SCBCD<br />MCSD<br />IBM Certified Specialist RUP v2003<br />IBM Certified Solution Designer OOAD vUML2<br /> <br />Phone Number:86-010-82776427
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
.
Setter methods for fields associated with the primary key must not be associated through a client view is correct or wrong



EJB specs page 130

Once the primary key for an entity bean has been set, the Bean Provider must not attempt to change it by use of set accessor methods on the primary key cmp-fields. The Bean Provider should therefore not expose the set accessor methods for the primary key cmp-fields in the component interface of the entity bean.


Although it won;t thown an exception if you expose the setter method but it is not a good practice.


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: can setter methods exist for primary key?
 
Similar Threads
reg Prim key class
Primary key question
Coffee cram No. 46
HFEJB question 46 from mock exam
Question on CMP virtual persistent fields