Skip to Main Content
Enterprise JavaBeans, Fourth Edition
book

Enterprise JavaBeans, Fourth Edition

by Sacha Labourey, Bill Burke, Richard Monson-Haefel
June 2004
Intermediate to advanced content levelIntermediate to advanced
792 pages
23h 17m
English
O'Reilly Media, Inc.
Content preview from Enterprise JavaBeans, Fourth Edition

Persistence Fields

Container-managed persistence (CMP) fields are virtual fields whose values map directly to the database. Persistence fields can be Java serializable types and Java primitive types. Java serializable types implement the java.io.Serializable interface. Most deployment tools easily handle java.lang.String, java.util.Date, and the primitive wrappers (Byte, Boolean, Short, Integer, Long, Double, and Float), because these types of objects are part of the Java core and map naturally to database fields.

The CustomerEJB declares three serializable fields, id, lastName, and firstName, which map naturally to the INT and CHAR fields of the CUSTOMER table in the database.

You can also define your own serializable types, called dependent value classes , and declare them as CMP fields. However, I recommend that you do not use custom serializable objects as persistence field types unless it is absolutely necessary—they are usually recommended for unstructured types, such as multimedia data (images, blobs, etc.). Arbitrary dependent value classes usually will not map naturally to database types, so they must be stored in their serializable forms in some type of binary database field.

Serializable objects are always returned as copies and not references, so modifying a serializable object will not impact its database value. The value of a serializable object must be updated using the set<field-name> method.

The primitive types (byte, short, int, long, double, float, and boolean

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Enterprise JavaBeans, Third Edition

Enterprise JavaBeans, Third Edition

Richard Monson-Haefel
Enterprise JavaBeans 3.1, 6th Edition

Enterprise JavaBeans 3.1, 6th Edition

Andrew Lee Rubinger, Bill Burke
Enterprise JavaBeans 3.0, 5th Edition

Enterprise JavaBeans 3.0, 5th Edition

Richard Monson-Haefel, Bill Burke

Publisher Resources

ISBN: 059600530XSupplemental ContentCatalog PageErrata