![Red Hat Application Server Скачать руководство пользователя страница 92](http://html.mh-extra.com/html/red-hat/application-server/application-server_manual_1427406092.webp)
84
Chapter 8. Developing Entity Beans
return null;
}
If nothing else is specified and the JOnAS default CMP 2 database mapping is used, the JOnAS
container generates a database column with the name
JPK_
to handle this PK. However, it is possible
to specify in the JOnAS-specific Deployment Descriptor the name of the column that will be used
to store the PK value in the table. You can do this as follows using the specific
(
automatic-pk-field-
name
)
element (this technique is necessary for CMP2 legacy and for CMP1):
JOnAS-specific deployment descriptor:
*
jonas-ejb-jar xmlns="http://www.objectweb.org/jonas/ns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.objectweb.org/jonas/ns
http://www.objectweb.org/jonas/ns/jonas-ejb-jar_4_0.xsd"
+
*
jonas-entity
+
*
ejb-name
+
AddressEJB
*
/ejb-name
+
*
jdbc-mapping
+
*
jndi-name
+
jdbc_1
*
/jndi-name
+
*
automatic-pk-field-name
+
FieldPkAuto
*
/automatic-pk-field-name
+
*
/jdbc-mapping
+
*
/jonas-entity
+
8.4.1.1.2. Method 2: CMP Field as Automatic Primary Key (from JOnAS 3.3.x)
The idea here is to declare a typical PK CMP field of type
java.lang.Integer
as
automatic
.
By doing this, the field will no longer appear in
create
methods and its value will be automatically
generated by the container at the EJB instance-creation time. However, it is still a cmp field, with
getter/setter methods, and is accessible from the application.
8.4.1.1.2.1. Method 2 Example:
In the standard deployment descriptor, there is a typical primary key definition:
*
entity
+
...
*
prim-key-class
+
java.lang.Integer
*
/prim-key-class
+
*
cmp-field
+
*
field-name
+
id
*
/field-name
+
*
/cmp-field
+
*
primkey-field
+
id
*
/primkey-field
+
In the JOnAS-specific deployment descriptor, specify that this PK is automatic:
*
jonas-entity
+
...
*
jdbc-mapping
+
*
automatic-pk
+
true
*
/automatic-pk
+
Содержание Application Server
Страница 1: ...Red Hat Application Server JOnAS User Guide ...
Страница 8: ......
Страница 22: ...14 Chapter 1 Java Open Application Server JOnAS a J2EE Platform ...
Страница 58: ...50 Chapter 3 JOnAS Configuration ...
Страница 66: ...58 Chapter 5 JOnAS Class Loader Hierarchy ...
Страница 78: ...70 Chapter 6 JOnAS Command Reference ...
Страница 80: ......
Страница 86: ...78 Chapter 7 Developing Session Beans ...
Страница 136: ...128 Chapter 9 Developing Message Driven Beans ...
Страница 142: ...134 Chapter 10 Defining the Deployment Descriptor ...
Страница 148: ...140 Chapter 11 Transactional Behavior of EJB Applications ...
Страница 158: ...150 Chapter 14 EJB Packaging ...
Страница 162: ...154 Chapter 15 Application Deployment and Installation Guide ...
Страница 164: ......
Страница 176: ...168 Chapter 18 WAR Packaging ...
Страница 178: ......
Страница 184: ...176 Chapter 20 Defining the Client Deployment Descriptor ...
Страница 186: ...178 Chapter 21 Client Packaging ...
Страница 188: ......
Страница 192: ...184 Chapter 23 EAR Packaging ...
Страница 194: ......
Страница 200: ...192 Chapter 24 JOnAS Services ...
Страница 204: ...196 Chapter 25 JOnAS and the Connector Architecture ...
Страница 222: ...214 Chapter 27 Ant EJB Tasks Using EJB JAR ...
Страница 234: ...226 Chapter 29 Web Services with JOnAS ...
Страница 236: ......
Страница 260: ...252 Chapter 34 How to use Axis in JOnAS ...
Страница 270: ...262 Chapter 36 Web Service Interoperability between JOnAS and BEA WebLogic ...
Страница 296: ......