web server - Borland Technical Publications
web server - Borland Technical Publications web server - Borland Technical Publications
Container-Managed Persistence in Borland Enterprise Server There are two classes that represent the entities which correspond to these tables, the Address and Country classes. The Address class contains a direct pointer, country, to the Country entity. This direct pointer reference is an EJBObject reference; it is not a direct Java reference to the implementation bean. Now examine the code for both classes: //Address Class public class Address extends EntityBean { public int id; public String street1; public String street1; public String city; public String state; public String zip; public Country country; // this is a direct pointer to the Country } //Country Class public class Country extends EntityBean { public int id; public String name; public int exchange; public String currency; } In order for the Container to resolve the reference from the Address class to the Country class, you must specify information about the Country class in the deployment descriptor. Using the entry in the deployment descriptor, you instruct the Container to link the reference to the field Address.country to the JNDI name for the home object, CountryHome. (Look at the pigs example for a more detailed explanation.) The container optimizes this cross-entity reference; because of the optimization, using the cross reference is as fast as storing the value of the foreign key. However, there are two important differences between using a cross reference and storing the foreign key value: ■ ■ When you use a cross reference pointer to another entity, you do not have to call the other entity's home object findByPrimaryKey() method to retrieve the corresponding object entity. Using the above example as an illustration, the Address.country pointer to the Country object lets you retrieve the country object directly. You do not have to call CountryHome.findByPrimaryKey(address.country) to get the Country object that corresponds to the country id. When you use a cross reference pointer, the state of the referenced entity is only loaded when you actually use it. It is not automatically loaded when the entity containing the pointer is loaded. That is, merely loading in an Address object does not actually load in a Country object. You can think of the Address.country field as a “lazy” reference, though when the underlying object is actually used does a “lazy” reference load in its corresponding state. (Note that this “lazy” behavior is a part of the EJB model.) This facet of the EJB model results in the decoupling of the life cycle of Address.country from the life cycle of the Address bean instance itself. According to the model, Address.country is a normal entity EJBObject reference; thus, the state of Address.country is only loaded when and if it is used. The Container follows the EJB model and controls the state of AddressBean.country as it does with any other EJBObject. Container-managed field names The Borland Container has changed the container-managed persistent field names so that they are more Java friendly. SQL column names often prepend a shortened form of the table name, followed by an underscore, to each column name. For example, in the address table, there is a column for the city called addr_city. The full reference to this column is address.addr_city. With the Borland Container, this maps to the Java Chapter 14: Entity Beans and CMP 1.1 in Borland Enterprise Server 119
Setting Properties Setting Properties field Address.city, rather than the more redundant and more awkward Address.addr_city. You can achieve this Java-friendly column-to-field-name mapping using the deployment descriptor. While this section shows you how to manually edit the deployment descriptor, it is best to use the Deployment Descriptor Editor GUI to accomplish this. See the User’s Guide for instructions on using the GUI screens. Should you choose to manually edit the deployment descriptor, use the , , and subtags within the tag. Place the more friendly Java field name in the tag, noting that it is referencing a JDBC column. Put the type of the field in the tag. Lastly, place the actual SQL column name in the tag. The following deployment descriptor code segment illustrates this: ejb.cmp.jdbc.column:city String addr_city Most properties for Enterprise JavaBeans can be set in their deployment descriptors. The Borland Deployment Descriptor Editor (DDEditor) also allows you to set properties and edit descriptor files. Use of the Deployment Descriptor Editor is described in the Borland Enterprise Server User's Guide. Use properties in the deployment descriptor to specify information about the entity bean's interfaces, transaction attributes, and so forth, plus information that is unique to an entity bean. In addition to the general descriptor information for entity beans, here are also three sets of properties that can be set to customize CMP implementations, entity properties, table properties, and column properties. Entity properties can be set either by the EJB Designer Tab in the Deployment Descriptor Editor or in the XML directly. Using the Deployment Descriptor Editor You can use the Deployment Descriptor Editor, which is part of the Borland Enterprise Server AppServer Edition, to set up all of the container-managed persistence information. You should refer to the Borland Enterprise Server User's Guide for complete information on the use of the Deployment Descriptor Editor and other related tools. J2EE 1.2 Entity Bean using BMP or CMP 1.1 Table 14.1 J2EE 1.2 Entity Bean using BMP or CMP 1.1 Descriptor Element Navigation Tree Node/ Panel Name DDEditor Tab Entity Bean name Bean General Entity Bean class Bean General Home Interface Bean General Remote Interface Bean General Home JNDI Name Bean General Persistence Type (CMP or BMP) Bean General Primary Key Class Bean General Reentrancy Bean General Icons Bean General 120 BES Developer’s Guide
- Page 79 and 80: Web-enabling your CORBA server Impo
- Page 81 and 82: Configuring your Apache web server
- Page 83 and 84: Configuring your Apache web server
- Page 85 and 86: Web Services and Partitions ■ ■
- Page 87 and 88: Web Service providers Java:RPC prov
- Page 89 and 90: How Borland Web Services work
- Page 91 and 92: Packaging Web Service Application A
- Page 93 and 94: Tools Overview Java2WSDL tool Note
- Page 95 and 96: 84 BES Developer’s Guide
- Page 97 and 98: Client view of an enterprise bean L
- Page 99 and 100: Client view of an enterprise bean E
- Page 101 and 102: Managing transactions Managing tran
- Page 103 and 104: Support for JNDI Support for JNDI T
- Page 105 and 106: EJB to CORBA mapping A CORBA progra
- Page 107 and 108: 96 BES Developer’s Guide
- Page 109 and 110: Application Client architecture Pac
- Page 111 and 112: Document Type Definitions (DTDs) my
- Page 113 and 114: Support of references and links The
- Page 115 and 116: Use of Manifest files Use of Manife
- Page 117 and 118: 106 BES Developer’s Guide
- Page 119 and 120: Sessions in secondary storage If yo
- Page 121 and 122: 110 BES Developer’s Guide
- Page 123 and 124: Container-managed persistence and R
- Page 125 and 126: Implementing an entity bean Generat
- Page 127 and 128: Container-Managed Persistence in Bo
- Page 129: Container-Managed Persistence in Bo
- Page 133 and 134: Setting Properties into a BLOB. The
- Page 135 and 136: Setting Properties Automatic table
- Page 137 and 138: 126 BES Developer’s Guide
- Page 139 and 140: Container-managed persistence and R
- Page 141 and 142: Container-Managed Persistence in Bo
- Page 143 and 144: Container-Managed Persistence in Bo
- Page 145 and 146: Container-Managed Persistence in Bo
- Page 147 and 148: Container-Managed Persistence in Bo
- Page 149 and 150: Container-Managed Persistence in Bo
- Page 151 and 152: Container-Managed Persistence in Bo
- Page 153 and 154: 142 BES Developer’s Guide
- Page 155 and 156: Setting Properties J2EE 1.3 Entity
- Page 157 and 158: Setting Properties Figure 16.2 Edit
- Page 159 and 160: Setting Properties Table 16.1 ejb.m
- Page 161 and 162: Setting Properties Table 16.3 Table
- Page 163 and 164: Setting Properties Security Propert
- Page 165 and 166: Aggregate Functions in EJB-QL Selec
- Page 167 and 168: Support for ORDER BY Support for OR
- Page 169 and 170: Overriding SQL generated from EJB-Q
- Page 171 and 172: Container-managed data access suppo
- Page 173 and 174: 162 BES Developer’s Guide
- Page 175 and 176: Generating primary keys from a cust
- Page 177 and 178: Implementing primary key generation
- Page 179 and 180: Transaction manager services Consis
Setting Properties<br />
Setting Properties<br />
field Address.city, rather than the more redundant and more awkward<br />
Address.addr_city.<br />
You can achieve this Java-friendly column-to-field-name mapping using the<br />
deployment descriptor. While this section shows you how to manually edit the<br />
deployment descriptor, it is best to use the Deployment Descriptor Editor GUI to<br />
accomplish this. See the User’s Guide for instructions on using the GUI screens.<br />
Should you choose to manually edit the deployment descriptor, use the ,<br />
, and subtags within the tag.<br />
Place the more friendly Java field name in the tag, noting that it is<br />
referencing a JDBC column. Put the type of the field in the tag. Lastly,<br />
place the actual SQL column name in the tag. The following<br />
deployment descriptor code segment illustrates this:<br />
<br />
ejb.cmp.jdbc.column:city<br />
String<br />
addr_city<br />
<br />
Most properties for Enterprise JavaBeans can be set in their deployment descriptors.<br />
The <strong>Borland</strong> Deployment Descriptor Editor (DDEditor) also allows you to set properties<br />
and edit descriptor files. Use of the Deployment Descriptor Editor is described in the<br />
<strong>Borland</strong> Enterprise Server User's Guide. Use properties in the deployment descriptor to<br />
specify information about the entity bean's interfaces, transaction attributes, and so<br />
forth, plus information that is unique to an entity bean. In addition to the general<br />
descriptor information for entity beans, here are also three sets of properties that can<br />
be set to customize CMP implementations, entity properties, table properties, and<br />
column properties. Entity properties can be set either by the EJB Designer Tab in the<br />
Deployment Descriptor Editor or in the XML directly.<br />
Using the Deployment Descriptor Editor<br />
You can use the Deployment Descriptor Editor, which is part of the <strong>Borland</strong> Enterprise<br />
Server AppServer Edition, to set up all of the container-managed persistence<br />
information. You should refer to the <strong>Borland</strong> Enterprise Server User's Guide for<br />
complete information on the use of the Deployment Descriptor Editor and other related<br />
tools.<br />
J2EE 1.2 Entity Bean using BMP or CMP 1.1<br />
Table 14.1 J2EE 1.2 Entity Bean using BMP or CMP 1.1<br />
Descriptor Element<br />
Navigation Tree Node/<br />
Panel Name<br />
DDEditor Tab<br />
Entity Bean name Bean General<br />
Entity Bean class Bean General<br />
Home Interface Bean General<br />
Remote Interface Bean General<br />
Home JNDI Name Bean General<br />
Persistence Type (CMP or BMP) Bean General<br />
Primary Key Class Bean General<br />
Reentrancy Bean General<br />
Icons Bean General<br />
120 BES Developer’s Guide