Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Question on initial "field values"

Your exception doesn't show the underlying exceptions stack trace - where the NPE is being thrown from. 

Anyway, no, you cannot call event.updateAttributeWithObject("dirty", false);
unless the attribute "dirty" is mapped - this code relies on the mapping to set the attribute in the object. 

What are you trying to do though?  The initial problem seemed to be that the dirty field is being set to true - are you setting
this field in your accessor methods?  If so, is your entity using property access or field access.  If it is using property access,
could it be that loading the entity is setting those field because it must use the entities accessors? 

 I am not sure why you want to use merge, but since it is not transient, you would set the field
on the object directly - location.dirty = false;  You might want to look at using postLoad event to reset your transient dirty fields when the Entity is loaded from the
database or when it gets refreshed.   This will cover the case where you are loading an entity from the shared cache or the database. 

Best Regards,

On 01/12/2010 3:07 PM, Kevin Haskett wrote:
Here is the stack trace after executing this code -
    public void postMerge(DescriptorEvent event) {
        CpLocation location = (CpLocation)event.getObject();
        boolean dirty = location.isDirty();
        if (dirty) {
            event.updateAttributeWithObject("dirty", false);

Could not commit JPA transaction; nested exception is
javax.persistence.RollbackException: java.lang.NullPointerException}
org.springframework.transaction.TransactionSystemException: Could not
commit JPA transaction; nested exception is
javax.persistence.RollbackException: java.lang.NullPointerException;
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAo;at $Proxy55.update(Unknown Source);at

Any ideas?

-----Original Message-----
From: Kevin Haskett 
Sent: Monday, November 29, 2010 4:42 PM
To: Kevin Haskett; 'EclipseLink User Discussions'
Subject: RE: [eclipselink-users] Question on initial "field values"

So I tried adding some code to the postMerge event,
event.updateAttributeWithObject("dirty", Boolean.FALSE);

But unfortunately I get a null pointer error. Is this because the
attribute is a boolean and not a full fledged object or is it because
its not a true field?


-----Original Message-----
From: Kevin Haskett 
Sent: Monday, November 29, 2010 11:53 AM
To: eclipselink-users@xxxxxxxxxxx
Subject: RE: [eclipselink-users] Question on initial "field values"

I have tried adding code to the postMerge event, but this seems like it
is too late in the process.  Is there an event that would fire when the
record was initially read?

-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of James
Sent: Wednesday, November 24, 2010 9:32 AM
To: eclipselink-users@xxxxxxxxxxx
Subject: Re: [eclipselink-users] Question on initial "field values"

Have you marked the fields as @Transient?

For the existing object, were these fields set previously?  They may
have the existing values from the persistence context, or shared cache.
you do not want them cached you can clear them using a descriptor merge
event, or instantiation copy policy.

khaskett wrote:
I have a domain object that extends a "base domain" object. This base
domain object has some Boolean fields that aren't fields on the table
but are there to track certain changes that might occur during the
lifetime of the domain object.  It seems fine when I do a "new" on the
object the fields are defaulted to "false" correctly, but when I do a
find on an existing object, the values for these tracking fields seem
be mixed.

abstract class BaseBomainClass {

private Boolean trackingfield;




public class DomainClass extends BaseDomainClass {



How are these field values set?



This message (including any attachments) is intended only for
the use of the individual or entity to which it is addressed and
may contain information that is non-public, proprietary,
privileged, confidential, and exempt from disclosure under
applicable law or may constitute as attorney work product.
If you are not the intended recipient, you are hereby notified
that any use, dissemination, distribution, or copying of this
communication is strictly prohibited. If you have received this
communication in error, notify us immediately by telephone and
(i) destroy this message if a facsimile or (ii) delete this message
immediately if this is an electronic communication.

Thank you.


----- James
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
Blog: Java

Back to the top