jQuery in Action, 3rd edition
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Enthuware question com.enthuware.ets.scbcd.v5.2.79 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.79" Watch "Enthuware question com.enthuware.ets.scbcd.v5.2.79" New topic

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

Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
What should be done to ensure that a field in an entity class is NOT persisted to the database?

a) make it transient using the transient keyword
b) Annotate it with @NotPersistent
c) Annotate it with @Transient
d) Do not annotate it with @Persistent
e) Use transient keyword as well as annotate it with @NotPersistent.

The answer they give is c), this is correct. But I think a) is also correct? Their explanation why a) is incorrect is:
Transient keywork only prevents file I/O serialization. It is not useful in this case.

but here is an excerpt from the specs (2.1.1 Persistent fields and properties, page 18):

If the entity has field-based access, the persistence provider runtime accesses instance variables
directly. All non-transient instance variables that are not annotated with the Transient
annotation are persistent. When field-based access is used, the object/relational mapping anno-
tations for the entity class annotate the instance variables.


Mapping annotations cannot be applied to fields or properties that are transient or Tran-

What do you ranchers think?
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3635
From the section of the specification that you've referred, it seems clear that even making the field trasient will work. So I think it should be fixed

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