ObjectDB ObjectDB

Class fields selection to store

#1

In a class how do I define which are the fields to be stored? (using JDO API)

It's using persistence-modifier="persistent" ?

If I have a class with 40 fields and I only want to store one of the fields should I do the following?

<class name="Car">
   <field name="Wheels" persistence-modifier="persistent" />
</class>

Which are the value used for fields that I do not want to store?

Which are the value used as default? e.g <class name="Car">

 

Thanks in Advance

 

 

edit
delete
#2

All the non static non final non transient fields in a persistence capable class are persistent by default. Therefore you don't need an XML element for the persistent field but for the other 39 non persistent fields.

Alternatively, you may:

  • Define the other 39 fields as transient (but then they will be transient also in serialization).
  • Annotate the other 39 fields using @NonPersistent (starting JDO 2.1 you can use annotations instead of XML metadata).
ObjectDB Support
edit
delete

Reply

To post on this website please sign in.