Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] problems with Allow Null in web service on Glassfish 3.1.2

In 2.3.2 an embedded object is required to be a non-null if it has any reference mappings (OneToOne, OneToMany, ManyToOne, ManyToMany) or ElementCollection.

In 2.3.3 (to be released very soon) embedded object that has OneToOne (not target foreign key - not "mappedBy" an inverse mapping) mapping is allowed to be null.

A (hacky) workaround in 2.3.2 would be setting isNullAllowed flag on the mapping AFTER the session has connected using the following SessionCustomizer:

public class MyCustomizer implements SessionCustomizer {
    public void customize(Session session) {
session.getEventManager().addListener(new org.eclipse.persistence.sessions.SessionEventAdapter(){
            public void postLogin(SessionEvent event) {
(AggregateObjectMapping)session.getDescriptor(MyClass.class).getMappingForAttributeName("popl")).setIsNullAllowed(true);
            }
        });
    }
}

On 6/29/2012 3:49 AM, petrxn@xxxxxxxxxx wrote:
Hello
I would like to ask you for an advice or a direction where to find some
example about how to solve my problem. I have web service which is running
smoothly on Glassfish 2.1.1. and I am trying to migrate to Glassfish 3.1.2,
but the web service is not working there.
I am getting this error from server.log:
…
Stack:
Exception [EclipseLink-68] (Eclipse Persistence Services -
2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The value of an aggregate in object […@c950b5] is
null. Null
values not allowed for Aggregate mappings unless "Allow Null" is specified.
Mapping: org.eclipse.persistence.mappings.AggregateObjectMapping[popl]
Descriptor: RelationalDescriptor
…


[popl] from the next-to-last line of the exception is an Embedded
parametr of
an entity class. It is not mandatory parametr and i am getting the error
when the parametr is not there. If it is there than there is no error
I tried to google it and to set DescriptorCustomizer for the entity class
with parametr Allow null as in short below
@Entity
@Table …
@Customizer(EntType.class)
public class EntType implements Serializable, DescriptorCustomizer {
…
@Embedded
protected poplType popl ;
…
public void customize(ClassDescriptor descriptor) {

((AggregateObjectMapping)descriptor.getMappingForAttributeName("popl")).setIsNullAllowed(true);
}
}
And it is still not working :(, can you help me with advice how to do
it, what can be cause of the error or where to find some example about
this problem?
Thank You very much
With Regards Petr N



_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top