[jboss-user] [EJB 3.0] - Re: @embedable annotation

itsme do-not-reply at jboss.com
Tue Mar 10 04:56:35 EDT 2009


For the first one (use of @Embaddable and @Embedded) Customer class must be changed to:

  | @Entity
  | public class Customer implements Serializable {
  |     // ... your member fields
  |     private Address address;
  |     // ... your set-/get-Methods
  |     @Embedded
  |     public Address getAddress() {
  |         return address;
  |     }
  |     // ... setter as well
  | }
  | 

For the second one (keeping @Embeddable and building a wrapper):

  | @Entity
  | public class AddressWrapper implements Serializable {
  |     
  |     @Id
  |     private String id;
  | 
  |     @Embedded
  |     private Address address;
  | 
  |     // getter and setter
  | }
  | 
In this case your Customer class must be changed like

  | @Entity
  | public class Customer implements Serializable {
  |     // ... your member fields
  |     private AddressWrapper address;
  |     // ... your set-/get-Methods
  |     @OneToOne
  |     public AddressWrapper getAddress() {
  |         return address;
  |     }
  |     // ... setter as well
  | }
  | 
For the last one you must change the annotation of Address to @Entity and change your Customer class like the above (without Wrapper).

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4216472#4216472

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4216472



More information about the jboss-user mailing list