Chapter 8 Creating J2EE Applications for BEA WebLogic
In container-managed persistence, you use groups to specify certain persistent attributes of an entity bean. A field-group represents a subset of the cmp and cmr-fields of a bean. You can put related fields in a bean into groups that are considered into memory together as a unit. You can associate a group with a query or relationship, so that when a bean is loaded as the result of executing a query or following a relationship, only the fields mentioned in the group are loaded.
A special group named "default" is used for queries and relationships that have no group specified. By default, the default group contains all of a bean's cmp-fields and any cmr-fields that add a foreign key to the persistent state of the bean.
A field can belong to multiple groups. In this case, the getXXX() method for the field will fault in the first group that contains the field.
Field groups are specified in the weblogic-rdbms-cmp-jar.xml file as follows:
<group-name>financial-data</group-name> <group-name>medical-data</group-name> <cmr-field>patient</cmr-field> <cmr-field>doctors</cmr-fields> <cmr-field>insurance-providers</cmr-fields>
You use field groups when you want to access a subset of fields.
The field group is an optimizing element that should be used with care because it is possible to corrupt the database. For example:
getA() // loads A and B modify A // then an external process modifies the row getC()
Because C is not in the group, there are two possibilities:
In both cases, the database will be corrupted. The reason is that you told the container that within this transaction, only A and B would be read, but instead C also was read. The correct step to take would have been to add C to the group or to specify no groups at all.
Copyright (C) 2005. Sybase Inc. All rights reserved. |
![]() |