Skip to Main Content
Enterprise JavaBeans 3.1, 6th Edition
book

Enterprise JavaBeans 3.1, 6th Edition

by Andrew Lee Rubinger, Bill Burke
September 2010
Intermediate to advanced content levelIntermediate to advanced
766 pages
18h 35m
English
O'Reilly Media, Inc.
Content preview from Enterprise JavaBeans 3.1, 6th Edition

Property Mappings

So far, we have only shown how to specify column mappings for simple primitive types. There are still a few bits of metadata that you can use to fine-tune your mappings. In this section, you’ll learn more annotations for more complex property mappings. Java Persistence has mappings for JDBC Blobs and Clobs, serializable objects, and embeddable objects, as well as optimistic concurrency with version properties. We discuss all of these.

@Transient

In our first example of our Employee bean class, we showed that the persistence manager would assume that every nontransient property (getter/setter or field, depending on your access type) in your bean class is persistent, even if the property does not have any mapping metadata associated with it. This is great for fast prototyping of your persistent objects, especially when your persistence vendor supports autotable generation. However, you may have properties that you don’t want to be persistent, and therefore this default behavior is inappropriate. For instance, let’s assume we want to express what an employee is currently doing without tying this information to persistent storage. We may very simply declare:

/**
 * Description of what the Employee's currently
 * working on.  We don't need to store this in the DB.
 */
@Transient
// Don't persist this
private String currentAssignment;

When you annotate a property with @javax.persistence.Transient, the persistence manager ignores it and doesn’t treat it as persistent.

@Basic and ...

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

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
JavaServer Faces

JavaServer Faces

Hans Bergsten
EJB 3 Developer Guide

EJB 3 Developer Guide

Michael Sikora

Publisher Resources

ISBN: 9781449399139Errata Page