File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Enthuware question com.enthuware.ets.scbcd.v5.2.69 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Enthuware question com.enthuware.ets.scbcd.v5.2.69" Watch "Enthuware question com.enthuware.ets.scbcd.v5.2.69" New topic

Enthuware question com.enthuware.ets.scbcd.v5.2.69

Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
Consider the following entity class:

public class Employee{
@Id int id;
String name;
Address addr;

Which of the following options are correct regarding the above code ...

a) Address class must implement Serializable.
b) Address class must be annotated with @Embeddable
c) Address class must be annotated with @Entity
d) The addr field must be annotated with @Lob.

The answer given is b), which is correct. The specs read (2.1.6 Mapping Defaults for Non-Relationship Fields or Properties, page 21/22):

If a persistent field or property other than a relationship property is not annotated with one of the map-
ping annotations defined in Chapter 9 (or equivalent mapping information is not specified in the XML
descriptor), the following default mapping rules are applied in order:
• If the type is a class that is annotated with the Embeddable annotation, it is mapped in the
same way as if the field or property were annotated with the Embedded annotation. See Sec-
tions 9.1.34 and 9.1.35.

which explains why b) is correct. But

If the type of the field or property is one of the following, it is mapped in the same way as it
would if it were annotated as Basic: Java primitive types, wrappers of the primitive types,
java.lang.String, java.math.BigInteger, java.math.BigDecimal,
java.util.Date, java.util.Calendar, java.sql.Date, java.sql.Time,
java.sql.Timestamp, byte[], Byte[], char[], Character[], enums, any other
type that implements Serializable. See Sections 9.1.18 through 9.1.21.

So, in my opinion, if the Address class implements serializable, and is NOT annotated Embeddable, it would also work, but store the property as a blob. So, a) would also be valid, wouldn't it?

What are you opinions?
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
I agree. See also the following link

SCJP 5 (98%) - SCBCD 5 (98%)
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3635
Thanks a lot for your feedback! You are right. It is has been fixed.

Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
I agree. Here's the link:
subject: Enthuware question com.enthuware.ets.scbcd.v5.2.69
It's not a secret anymore!