Display the Component Properties window in EAServer Manager and configure the following fields on the Persistence/General subtab:
Persistence For an EJB CMP entity bean, choose Generated Class. For components of other types, choose Automatic Persistent State.
Generated Class Name For an EJB CMP entity bean, optionally enter a class name for the generated subclass. If you do not specify a class name, the default is:
java-package._ps_package_component
Where java-package is the Java package of the implementation class, package is the EAServer package name, and component is the component name.
Primary Key Enter the name of the primary key type (see “Defining the primary key type”). If you have imported an EJB entity bean, the primary key has been defined already.
An EJB 2.0 entity bean that uses CMP and specifies java.lang.Object as the primary key class requires automatic key generation when deployed to EAServer. Components of other types can use this feature as well. See “Enabling automatic key generation”.
State If you have imported an EJB CMP entity bean from an EJB-JAR file, the state has been defined already. Otherwise, define the state type as described in “Defining the state datatype”.
State Methods If you are creating an EJB entity bean, enter “default”. If you are creating an entity component of another type, specify the names of the state accessor methods implemented by your component. See “Defining the state methods”.
Storage Component Specify the name of the storage component, as described in “Storage components”.
Connection Cache Enter the name of a JDBC connection cache that connects to
the database. The default for new components is JavaCache
. For
components that are imported from an EJB-JAR file, the default is
the value of the com.sybase.jaguar.server.defaultStorageCache server property.
The cache must:
Allow by-name access (configured on the Cache tab in the Connection Cache Properties dialog box).
Specify a database type. This property defines database-specific information required by the storage component, for example, the commands to verify a table exists and create new tables. Several predefined configurations are provided for popular databases, and you can create your own. For more information, see “Configuring connection caches” in the EAServer System Administration Guide.
Have a user name specified for the property com.sybase.jaguar.conncache.ssa.systemid if Set-Proxy support is enabled (com.sybase.jaguar.conncache.ssa is set to true). In an EJB CMP entity bean, the client user name is not available to set proxy to since the persistence engine runs as the system user.
For EJB CMP entity beans, EAServer supplys JDBC wrapper drivers that can improve performance through the use of deferred updates and stored procedures. For more information, see “Using CMP JDBC wrapper drivers” in the EAServer Performance and Tuning Guide.
Table If using mapped table fields, enter:
map:table
Where table is the database table name. “Creating database tables” describes how tables are created and made accessible to the storage component.
Timestamp Optionally specify a database timestamp column that EAServer uses for concurrency control. Using timestamps for concurrency control yields the best performance in most cases. See “Configuring concurrency control” for more information.
Create Database Triggers Applies if you have configured instance or query caching as described in “Entity instance and query caching” in the EAServer Performance and Tuning Guide, and you have enabled database change notification as described in that section. This option enables automatic creation of database triggers to notify the EAServer cache manager when the table data changes.
Select With Lock Configures data locking to enable pessimistic concurrency control. See “Configuring concurrency control” for more information.
WARNING! Carefully evaluate your concurrency control model before deploying your application. Concurrency control greatly affects performance as well as the integrity of your back-end database. See “Configuring concurrency control” for more information.
For automatic persistence, you must define a state datatype to be used for exchange of data between the component’s skeleton and the storage component.
State types for mapped fields If using the mapped-fields storage model, the state datatype must be an IDL structure. Enter the structure name in the in the State field on the Persistence/General subtab in the Component Properties Dialog box. For example:
MyPackage::CustomerState
You can enter the name of an IDL structure that does not exist; EAServer Manager creates it when you click Ok in the Component Properties dialog box. Afterwards, navigate to the IDL definition and edit the structure as described in “Editing IDL types, exceptions, and interfaces”.
Define the structure field names and types as follows:
For EJB 2.0 entity beans, specify one field for each container-managed field that is not part of the primary key and not a container-managed relationship field. Use the same name as the container-managed field. Choose the IDL type that matches the Java datatype, as listed in Table 29-2.
For EJB 1.1 entity beans, specify one field for each container-managed field that is not part of the primary key. Use the same name as the container-managed field. Choose the IDL type that matches the Java datatype, as listed in Table 29-2.
For non-EJB entity components, specify one field for each component field that is to be stored in the database table, excluding fields that are part of the primary key. Choose the IDL type that matches the field’s datatype in the implementation class, as listed in Table 29-2. If using timestamps for concurrency control, do not include an IDL field for the timestamp column. Your implementation class must contain state accessor methods to apply the field values to implementation fields, and populate the state type from instance field data. Specify the state accessor method names on the State Methods field on the Persistence/General subtab, as described in “Defining the state methods”.
State types for binary storage If you are using the binary storage model, enter the name of an IDL structure or serializable Java class. Your state accessor methods must contain code to get and set this data to and from the current instance, as described in “Defining the state methods”.
For automatic persistence in non-EJB components or in EJB
components using the binary-storage persistence model, your component
implementation must contain state accessor methods to read state
data from the current instance and apply state data to the current
instance. Specify the names of these methods on the State Methods
field in the Persistence/General subtab. If you specify
no value, the default is getState,setState
.
Your component implementation must contain these methods, but they should not be listed in the component’s client interfaces. The getState method returns an instance of the type specified by the State field, and the setState method accepts a parameter of this type. For example, if the State type is ShoppingCartState, the getState and setState methods might be defined as follows in Java:
private ShoppingCartState data; ShoppingCartState getState() { return data; } void setState(ShoppingCartState state) { data = state; }
Copyright © 2005. Sybase Inc. All rights reserved. |