users@glassfish.java.net

Lazy init of Embedded objects

From: <glassfish_at_javadesktop.org>
Date: Fri, 21 Sep 2007 08:27:45 PDT

A project is using static weaving (with StaticWeaveAntTask) for lazy evaluation of toOne relationships. On @Embedded objects, it does not seem to work.

Example:

[code]
@Entity
public class TechnicalService {
      @Embedded
        private ContactInfo contactInfo;
}
 
@Embeddable
public class ContactInfo {
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SERVICE_MANAGER_ID")
    private ContactBase serviceManager;
}
[/code]

The stacktrace looks like this:

[code]
Exception [TOPLINK-1] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: The attribute [serviceManager] is not declared as type ValueHolderInterface, but its mapping uses indirection.
Mapping: oracle.toplink.essentials.mappings.OneToOneMapping[serviceManager]
Descriptor: RelationalDescriptor(com.ford.volvocars.r2r.model.component.ContactInfo --> [DatabaseTable(TECHNICALSERVICE)])
        at oracle.toplink.essentials.exceptions.DescriptorException.attributeAndMappingWithIndirectionMismatch(DescriptorException.java:271)
        at oracle.toplink.essentials.internal.indirection.BasicIndirectionPolicy.validateDeclaredAttributeType(BasicIndirectionPolicy.java:265)
        at oracle.toplink.essentials.mappings.ForeignReferenceMapping.validateBeforeInitialization(ForeignReferenceMapping.java:871)
        at oracle.toplink.essentials.descriptors.ClassDescriptor.validateBeforeInitialization(ClassDescriptor.java:3505)
        at oracle.toplink.essentials.descriptors.ClassDescriptor.preInitialize(ClassDescriptor.java:2198)
        at oracle.toplink.essentials.mappings.AggregateObjectMapping.initialize(AggregateObjectMapping.java:618)
        at oracle.toplink.essentials.descriptors.ClassDescriptor.initialize(ClassDescriptor.java:1756)
[/code]

We appreciate your comments...

Haiwei
[Message sent by forum member 'hchen14' (hchen14)]

http://forums.java.net/jive/thread.jspa?messageID=236481