cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Malcolm Edgar" <malcolm.ed...@gmail.com>
Subject Cayenne and Adobe Flex Data Services
Date Thu, 10 Aug 2006 05:34:52 GMT
Hi All,

I am trying to intregrate Cayenne with Adobe Flex Data Services. I am
finding a nasty compatability problem between the 2 framework designs.

Adobe uses a POJO assembler pattern when it is sent a serialize
ActionScript object graph which it then turns into a Java object
graph. When working with Cayenne objects there are problems when it is
assembling objects.

I presume it creates the data objects using reflection
class.newInstance() and then it sets properties on these object, which
may be other Cayenne objects.  Unfortunately as it has not followed
the usage Cayenne pattern of :

DataContext.createAndRegisterNewObject(Class)

These objects have not DataContext and are unable to resolve their
relationships and throw NPE.

I have tried hacking a work around:

public class BaseEntity extends CayenneDataObject {
	
    private static final long serialVersionUID = 1L;

    public BaseEntity() {
        super();

        DataContext dataContext = null;
        try {
            dataContext = DataContext.getThreadDataContext();

        } catch (IllegalStateException ise) {
            dataContext = DataContext.createDataContext();
            DataContext.bindThreadDataContext(dataContext);
        }

        dataContext.registerNewObject(this);
    }
}

This works with the Adobe Data Services code, but it stuffs up the
Cayenne object validation when committing object for some reason.

org.objectstyle.cayenne.validation.ValidationException: [v.1.2 July 16
2006] Validation has failed.
Validation failure for com.avoka.eeo.entity.Submission.user: "user"
is required.
Validation failure for com.avoka.eeo.entity.Submission.type: "type"
is required.
Validation failure for com.avoka.eeo.entity.Submission.status:
"status"  is required.
	at org.objectstyle.cayenne.access.ObjectStoreGraphDiff.validateAndCheckNoop(ObjectStoreGraphDiff.java:132)
	at org.objectstyle.cayenne.access.DataContext.flushToParent(DataContext.java:1244)
	at org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:1165)
	at com.avoka.eeo.assembler.SubmissionAssemblerTestCase.testFillUsername(SubmissionAssemblerTestCase.java:22)
	at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
Source)
	at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown
Source)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



Any suggestions would be greatly appreciated.

regards Malcolm Edgar

Mime
View raw message