web server - Borland Technical Publications
web server - Borland Technical Publications web server - Borland Technical Publications
Container-Managed Persistence in Borland Enterprise Server CASE 1: A development environment without existing database tables using either JDataStore or Cloudscape databases. CASE 2: A deployment environment with (or without) existing database tables using supported databases. In this case, the Borland CMP engine creates tables automatically, assuming that the entity bean name is the same as the desired table name. You need only provide the bean's name and its associated datasource as a property: CustomerEJB ejb.datasource serial://ds/myDatasource The Borland CMP engine will automatically create tables in this datasource based on the bean's name and fields. In this case, you need to supply information on the tables to which the entities map. You'll provide a table name in the portion of the descriptor, and some properties in the portion: CustomerEJB CUSTOMER . . CUSTOMER datasource serial://ds/myDatasource Note that the datasource property is called datasource when specified in the element and ejb.datasource when in the element. If you are using a database other than JDataStore or Cloudscape and would like to have the Borland CMP engine automatically create this table, add the following XML to the element: . . CUSTOMER create-tables True Basic Mapping of CMP fields to columns Basic field mapping is accomplished using the element in the ejbborland.xml deployment descriptor. In this element, you specify a field name and a corresponding column to which it maps. Consider the following XML for an entity bean called LineItem, which maps two fields, orderNumber and line, to two columns, ORDER_NUMBER and LINE: LineItem orderNumber Chapter 15: Entity Beans and Table Mapping for CMP 2.0 133
Container-Managed Persistence in Borland Enterprise Server ORDER_NUMBER line LINE Mapping one field to multiple columns Many users may employ coarse-grained entity beans that implement a Java class to represent more fine-grained data. For example, an entity bean might use an Address class as a field, but may need to map elements of the class (like AddressLine1, AddressCity, and so forth) to an underlying database. To do this, you use the element, which defines a field map between your fine-grained class and its underlying database representation. Note that such classes must implement java.io.Serializable and all their data members must be public. Consider an entity bean called Customer that uses the class Address to represent a customer's address. The Address class has fields for AddressLine, AddressCity, AddressState, and AddressZip. Using the following XML, we can map the class to its representation in a database with corresponding columns: Customer . . Address Address.AddressLine STREET Address.AddressCity CITY Address.AddressState STATE Address.AddressZip ZIP . . Note that we use one element per database column. 134 BES Developer’s Guide
- 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 and 130: Container-Managed Persistence in Bo
- Page 131 and 132: Setting Properties Setting Properti
- 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: 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
- Page 181 and 182: Transaction manager services When t
- Page 183 and 184: Transaction manager services Follow
- Page 185 and 186: Declarative transaction management
- Page 187 and 188: Declarative transaction management
- Page 189 and 190: JDBC API Modifications JDBC API Mod
- Page 191 and 192: Handling of EJB exceptions Applicat
- Page 193 and 194: 182 BES Developer’s Guide
Container-Managed Persistence in <strong>Borland</strong> Enterprise Server<br />
CASE 1: A<br />
development<br />
environment without<br />
existing database<br />
tables using either<br />
JDataStore or<br />
Cloudscape databases.<br />
CASE 2: A deployment<br />
environment with (or<br />
without) existing<br />
database tables using<br />
supported databases.<br />
In this case, the <strong>Borland</strong> CMP engine creates tables automatically, assuming that the<br />
entity bean name is the same as the desired table name. You need only provide the<br />
bean's name and its associated datasource as a property:<br />
<br />
CustomerEJB<br />
<br />
ejb.datasource<br />
serial://ds/myDatasource<br />
<br />
<br />
The <strong>Borland</strong> CMP engine will automatically create tables in this datasource based on<br />
the bean's name and fields.<br />
In this case, you need to supply information on the tables to which the entities map.<br />
You'll provide a table name in the portion of the descriptor, and some<br />
properties in the portion:<br />
<br />
CustomerEJB<br />
<br />
CUSTOMER<br />
<br />
<br />
.<br />
.<br />
<br />
CUSTOMER<br />
<br />
datasource<br />
serial://ds/myDatasource<br />
<br />
<br />
Note that the datasource property is called datasource when specified in the <br />
element and ejb.datasource when in the element. If you are using<br />
a database other than JDataStore or Cloudscape and would like to have the <strong>Borland</strong><br />
CMP engine automatically create this table, add the following XML to the <br />
element:<br />
.<br />
.<br />
<br />
CUSTOMER<br />
<br />
create-tables<br />
True<br />
<br />
<br />
Basic Mapping of CMP fields to columns<br />
Basic field mapping is accomplished using the element in the ejbborland.xml<br />
deployment descriptor. In this element, you specify a field name and a<br />
corresponding column to which it maps. Consider the following XML for an entity bean<br />
called LineItem, which maps two fields, orderNumber and line, to two columns,<br />
ORDER_NUMBER and LINE:<br />
<br />
LineItem<br />
<br />
<br />
orderNumber<br />
Chapter 15: Entity Beans and Table Mapping for CMP 2.0 133