[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Refreshing objects with @Transient fields

Hi,

I have a number of @Transient fields, which are populated from an @PostLoad method, based on a char[] clob (eagerly fetched).

This fails in one specific case:

When an entity is loaded in a transaction, say with a null clob, then entityManager.refresh()'d, the clob is updated (now not null, due to changes in the database), but the transient fields are not updated.

With a little debugging, I found that the PostLoad method *is* called and the transient field is set, but this is all on a different instance of the entity.

It seems that eclipselink is performing the refresh operation on a clone of the entity, then copying the non-transient fields back to the object. Is this a bug?
Is there any workaround to try?


Further calls to find the entity from the same transaction have the same effect (new version of the clob, old version of the transient field). A call from a separate transaction returns the new version of the clob and transient field.

I've tried this with both 1.0.2 and 1.1.0 and get the same effect.

If it helps, here's the stack trace from when the @PostLoad method is called. this is invoked on a different entity to the one I'm refreshing.

at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.invokeMethod(PrivilegedAccessHelper.java:344)
at org.eclipse.persistence.internal.jpa.metadata.listeners.EntityListener.invokeMethod(EntityListener.java:297)
at org.eclipse.persistence.internal.jpa.metadata.listeners.EntityClassListener.invokeMethod(EntityClassListener.java:64)
at org.eclipse.persistence.internal.jpa.metadata.listeners.EntityListener.postRefresh(EntityListener.java:398)
at org.eclipse.persistence.descriptors.DescriptorEventManager.notifyListener(DescriptorEventManager.java:638)
at org.eclipse.persistence.descriptors.DescriptorEventManager.notifyEJB30Listeners(DescriptorEventManager.java:593)
at org.eclipse.persistence.descriptors.DescriptorEventManager.executeEvent(DescriptorEventManager.java:187)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:322)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:677)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:547)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:517)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:461)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:413)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:521)
at org.eclipse.persistence.queries.ReadObjectQuery.registerResultInUnitOfWork(ReadObjectQuery.java:707)
at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:431)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:879)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:666)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:840)
at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:398)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:902)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2587)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1178)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1162)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1108)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.refresh(EntityManagerImpl.java:423)
at org.apache.openejb.persistence.JtaEntityManager.refresh(JtaEntityManager.java:158)


Many thanks in advance for any help or ideas you give.

Regards,

Mark Howard