Data classes (access beans)

A data class is an access bean that is similar to a copy helper access bean, but it employs a different technology.

A data class provides the data storage and access methods for cacheable enterprise bean properties. You can define multiple data classes for an enterprise bean, each with a different set of cached properties. Data classes are supported with enterprise beans having both local and remote client views.

In copy helpers, a property cache is stored as a hash table within the access bean. However, in data classes, the cache is a container of the fields, getters, and setters needed to provide data storage and access of the cached properties. Also, the cache object remembers when properties are modified so that only dirty, or changed, properties are persisted when you commit the cache.

To create a data class, call the getXXXData method on the enterprise bean. To update the enterprise bean with the data stored in the data class, you can call either the syncXXXData or the setXXXData method on the enterprise bean, passing in the data class. The syncXXXData method causes any changes you have made to the data class to be written back to the enterprise bean. It returns a new instance of the data class that reflects the current data state of the bean. The setXXXData method throws an exception if an enterprise bean field is changed that has not been changed in the data class.

Getter and setter methods must be defined for your enterprise bean properties according to the JavaBeans conventions for defining getter and setter methods. If you don't have getter and setter methods, then you won't be able to add the corresponding fields to the copy helper. The getter and setter methods should also not throw any exceptions.

All data class access beans are serializable along with all their fields.

 

Parent topic

Access beans