JBoss.org Community Documentation
The EJB3 specification allows you to embed plain Java objects within your entities and map the properties of this embedded value object to columns within the entity's table.
The org.jboss.tutorial.embeddable.bean.Customer
entity encapsulates the name of the customer
in the org.jboss.tutorial.embeddable.bean.Name
value object. The
org.jboss.tutorial.embeddable.bean.Name
value object must be tagged with the @Embeddable
annotation.
@Embeddable public class Name implements java.io.Serializable
The properties of Name must then be mapped to columns within Customer's table.
@Embedded @AttributeOverrides({ @AttributeOverride(name = "first", column = {@Column(name = "FIRST_NAME")}), @AttributeOverride(name = "last", column = {@Column(name = "LAST_NAME")}) }) public Name getName() { return name; }
To build and run the example, make sure you have installed JBoss 5.x. See the Section 1.1, “JBoss Application Server 5.x” for details.
From the command prompt, move to the "embeddable" folder under the Section 1.3, “Set the EJB3_TUTORIAL_HOME”
Make sure your JBossAS-5.x is running
$ ant $ ant run run: [java] Create Bill Burke and Monica Smith [java] Bill and Monica get married [java] Get all the Burkes [java] There are now 2 Burkes
$ mvn clean install -PRunSingleTutorial
You can view the tables created by JBoss by going to the
Hypersonic Service,
scrolling down to the startDatabaseManager
button and clicking it.
A Hypersonic SQL window will be minimized, but you can open it up to look at the tables and do queries.