Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

and

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


What do you ranchers think?
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3712
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic