## Embeddable Objects

The EJB specification allows you to embed plain Java objects within your entity beans and map the properties of this embedded value object to columns within the entity's table.

The Customer bean encapsulates the name of the customer in the Name value object.

The 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;
       }

#### Building and Running

To build and run the example, make sure you have `ejb3.deployer` installed in JBoss 4.0.x and have JBoss running. See the reference manual on how to install EJB 3.0.

    Unix:    $ export JBOSS_HOME=<where your jboss 4.0 distribution is>
    Windows: $ set JBOSS_HOME=<where your jboss 4.0 distribution is>
    $ ant
    $ ant run

    run:
         [java] Create Bill Burke and Monica Smith
         [java] 2004-10-06 22:27:50,344 INFO org.jboss.remoting.InvokerRegistry[main] - Failed to load soap remoting transpo
    rt: org/apache/axis/AxisFault
         [java] Bill and Monica get married
         [java] Get all the Burkes
         [java] There are now 2 Burkes

The INFO message you can ignore. It will be fixed in later releases of JBoss 4.0.

#### View the tables and rows

You can view the tables created by JBoss by going to the Hypersonic SQL 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.

#### Jar structure

EJB 3.0 beans must be packaged in a JAR file with the suffix `.jar`. Running the ant script above creates a JAR file within the deploy/ directory of JBoss. All that needs to be in that jar is your server-side class files and additionally, you will probably need to define a hibernate.properties file in the META-INF directory of the JAR. hibernate.properties is needed if you need to hook in a datasource other than JBoss's DefaultDS, or change the caching of Hibernate. See the EJB 3.0 reference manual and Hibernate reference manual for more details.f