CloudTran Home

 
  
 
Contents  >   11.  CloudTran Profile Reference
 


11.3 Attribute Object

Used on
entity
Description An attribute in GigaSpaces is implicitly inSpace and persistent. For transient fields, use 'field'.
Contained
Lists
1
Name  constraint
Type  constraint
Description  Constraints for this field (or attribute).
GenerateAllList  false
Inherited
properties
text (base property)

 11.3.1  Property 'autokey'
 11.3.2  Property 'badValue'
 11.3.3  Property 'dbmsColumn'
 11.3.4  Property 'default'
 11.3.5  Property 'description'
 11.3.6  Property 'goodValue'
 11.3.7  Property 'index'
 11.3.8  Property 'key'
 11.3.9  Property 'name'
 11.3.10  Property 'required'
 11.3.11  Property 'type'
 11.3.12  Property 'versionController'
 11.3.13  Property 'whereIsIt'

11.3.1  Property 'autokey'
DescriptionSpecifies that automatic keys are to be used.

This implies a persistence model where a 'container' (e.g. the J2EE EJB container) can generate keys automatically.

It is the responsibility of the container's persistence manager to generate the run-time value for this field, which will be available after the entity is created.

By default, attributes are not autokey.

The type of the autokey attributes must be "Integer" or "Long" - the Java class wrappers for "int" and "long".

The type of the autokey attribute becomes the primary key class. Do not mark an autokey attribute as also a key attribute.
Typeboolean
Defaultfalse

11.3.2  Property 'badValue'
DescriptionAn unacceptable value for this parameter.

This can be used by test software to create test records automatically.
TypeString

11.3.3  Property 'dbmsColumn'
DescriptionSpecifies the DBMS column name where the attribute is persisted.

'dbmsColumn' is used when the attribute forms part of an entity bean and specifies the column name in the table in a DBMS store to where the attribute is persisted.
TypeString

11.3.4  Property 'default'
DescriptionSpecifies a default value to which the field will be set when created.

This is an expression which should be compatible with the field's 'type', or the generated program will not compile. For primitive types, this will typically be just the literal value of the default, although it can be an expression. Note that you should just specify the value part for numeric values, not a type-defining suffix. For example, you must specify "0" rather that "0L".

For non-string objects, the default should create an object - e.g. 'new Integer(8)'.

String defaults are assumed to be string literals less the surrounding "". They will have double-quotes added automatically, so the default is a String constant - e.g. Fred goes into the code as "Fred".

You can alter this action, to specify expressions for string defaults, by prefixing the expression with '\', which will be stripped off. You can also start and end the default string value with '"', in which case it will not be altered.

String examples:

input: Fred code: "Fred"

input: \otherfield.substring(1) code: otherfield.substring(1)

input: \"" code: ""

The default expression as processed by the above algorithm can be retrieved via the method getDefaultExpression().
TypeString

11.3.5  Property 'description'
DescriptionOptional description.

Use this to
  1. document the meaning of a particular item
  2. specify functionality at the design stage for implementation later.
TypeString

11.3.6  Property 'goodValue'
DescriptionAn acceptable value for this parameter.

This can be used by test software to create test records automatically.
TypeString

11.3.7  Property 'index'
Aliasindexed
DescriptionDefines if this attribute is indexed. Indexing speeds up access to objects in the space.

This will also be reflected in the generated database schema.
Typeboolean
Defaultfalse

11.3.8  Property 'key'
DescriptionIndicates whether attribute forms part of the primary key class.

'key' is either "true" or "false" and indicates whether the attribute forms part of the primary key class for the owning element.

It is ignored by stateful session beans and bean-managed entity beans.

The default value is "false".

'key' should not be specified [or specified as "false"] if 'autokey' is specified as "true" for any attributes of the bean.
Typeboolean
Defaultfalse

11.3.9  Property 'name'
DescriptionSpecifies the identifier for the field or parameter. This must follow the rules for identifiers (start with a letter or '_', not include '.' etc.).
TypeString
Requiredtrue

11.3.10  Property 'required'
DescriptionThis determines whether a value needs to be input into this attribute. We refer to attributes with required="true" as 'required' attributes, otherwise as 'optional'.

It is mainly relevant to attributes on entities. It is equivalent to 'NOT NULL' at the database level. The standard patterns use this property to
  • propagate 'null' to persistent storage (if unset)
  • enforce values are present before storage (if set)
  • enforce entry of values into screens (if set).
This field applies to strings (text fields), dates and references to other objects.

There is a similar property on data-views. The standard patterns that create data-views from entities propagate this property from the entity to the corresponding data-view.

Because primitive types cannot be 'unset' - they always have a value - they will alway set a non-null value in persistent storage. Primitive/value types are ones that are defined by the language and passed as atomic values - like 'int', 'short', 'char' and 'boolean'. Therefore the only meaning of setting a 'required' attribute for these values is so that it can be propagated by the standard patterns to require entry of a value into a screen.

If you do need to be able to control whether null values can be propagated to persistent storage, use the object type rather than the primitive type. For example, use 'Integer', 'Short', 'Character, 'Boolean' rather than the primitive types. By using these types, you will be able to determine whether a value is present (a non-null reference) or missing (a null reference). Of course this feature comes at a price, namely the incovenience of using the object versions.

Note the following points about processing nulls and empty object types (like Strings or Booleans):

  1. If the attribute is required and no default is specified, the attribute is initialised with an empty object (an empty string, a Boolean false etc.). This only applies to required attributes, not optional ones. This is done at the entity and data-view levels.

  2. There is a delegated property - 'convert-empty-strings-to-null' - which when set causes empty values input (e.g. on screens) into optional values, to be converted to null. This property is present on the attribute or data-view-field and their parents. This property has no effect on required values. By default, this property is set, because without it there is no way to express 'no value' on input screens.

  3. A 'required' String value means that the string must be non-null - i.e. there must be a string object available - but in this case the empty string is allowed. To specify that a String value must be non-empty, use a constraint with min-length=1.
Typeboolean

11.3.11  Property 'type'
DescriptionSpecifies the object type and may be the name of a primitive type or a class.

If the type is a class and the code requires you to qualify it (because it is ambiguous in one or more compiled files) you will have to add the qualifying package information yourself.

To specify an array, add '[]' on the end of the type, just as you would in a normal array declaration.
TypeString
DefaultString

11.3.12  Property 'versionController'
DescriptionIndicates whether attribute is used to validate concurrent changes on update. If data is picked up by a user and updated, the version-controller field may be used to test whether someone else has altered the record in the interim. If the property on the entity versionControl=true (also set globally in system.properties) an altered validator field will cause a runtime error.
Typeboolean
Defaultfalse

11.3.13  Property 'whereIsIt'
DescriptionTells how the attribute is held.

Normally, data is 'inMemoryAndPersistentStore', in which case it is derived from user or program input. In this case, CloudTran automatically maps it back and forth between memory and the persistent store (e.g. the database). For JDBC databases, CloudTran does the transformation; for non-JDBC databases, the developer has to provide the mapping in the load and store classes. This attribute will have a corresponding field in the in-memory data object and on the persistent store.

You can specify 'inMemoryOnly', in which case it is in memory but not in the persistent store. If the inMemoryOnly attribute is to be derived from other attributes in the entity, this can be done in the 'onLoad()' method in the Data (e.g. 'CustomerData') class for the entity. onLoad() is called just before the object is loaded into the space via CloudTran - either on initial load from the database or on create/update from applications.

You can also specify 'inPersistentStoreOnly', in which case it is in the persistent store but not in memory. In this case, this attribute will be present on the persistent store but will not have a corresponding field in the in-memory Data class for the entity. If the inPersistentStoreOnly attribute is to be derived from other attributes in the entity, this can be done in the 'onStore()' method, which is called just before the object is persisted.
TypeString
Choices
inMemoryAndPersistentStore (default)
inMemoryOnly
inPersistentStoreOnly
Requiredtrue

Copyright (c) 2001-2011 CloudTran Inc.