Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Question about Embeddable Classes

Hi, 

the JPA 1.0 specification says about embeddable classes
- "Support for only one level of embedding is required by this
specification."
- "Support for collections of embedded objects and for the polymorphism
and inheritance of embeddable classes will be required in
a future release of this specification."

I did a test with the following classes that worked fine:

@Entity
public class MyRecordImpl{

  @Id
  @Column(name = "ID")
  private String _id;

  @Embedded
  private MyAttributeImpl _attribute;
}

@Embeddable
public class MyAttributeImpl{

  @Column(name = "ATT_NAME")
  private String _name;

  @Column(name = "ATT_VALUE")
  private String _value;

  @Embedded
  @Column(name = "ANNOTATION")
  private MyAnnotationImpl _annaotation;
}

@Embeddable
public class MyAnnotationImpl{

  @Column(name = "ANON_NAME")
  private String _name;

  @Column(name = "ANON_VALUE")
  private String _value;
}

Does eclipseLink support more than one level of embedding or did this
just function by accident ?
How many levels are supported ?


Would it be possible to recursively embed objects, like 

@Entity
public class MyRecordImpl{

  @Id
  @Column(name = "ID")
  private String _id;

  @Embedded
  private MyAttributeImpl _attribute;
}

@Embeddable
public class MyAttributeImpl{

  @Column(name = "ATT_NAME")
  private String _name;

  @Column(name = "ATT_VALUE")
  private String _value;

  @Embedded
  @Column(name = "REF_ATTRIBUTE")
  private MyAttributeImpl _attribute;
}

When I try this I get a java.lang.StackOverflowError, presumably because
of the recursion.


Also I've read that eclipseLink supports collections of embeddable and
that it is set through using a DescriptorCustomizer and the
AggregateCollectionMapping. Are there any examples in the wiki ? I found
some documentation that I was unable to understand.
I guess something like  private List<MyAttributeImpl> _attributes; as a
member of MyAttributeImpl would still not be supported.


Bye,
Daniel



Back to the top