Yes, it's related.
- Jason

On Sat, Sep 19, 2009 at 10:32 AM, objectuser <[email protected]>wrote:

>
> Jason, is it also true that you can't have two one-to-one
> relationships of the same kind?  I'm able to save such a relationship,
> but when I fetch it, I get the same child in both values.  I need to
> debug further (would not be surprised if it's just something I'm doing
> wrong), but wondering if it's just a known issue.
>
> On Sep 17, 4:12 pm, "Jason (Google)" <[email protected]> wrote:
> > This is a known issue. At present, you can't have both a one-to-one and
> > one-to-many relationship of the same kind.
> > - Jason
> >
> > On Tue, Sep 15, 2009 at 2:57 PM, Tim <[email protected]> wrote:
> >
> > > It appears that these two statements work individually but not
> > > together.
> >
> > >    @Persistent
> > >    private ContactInfo        manager;
> > >    @Persistent
> > >    private List<ContactInfo>  staff = new ArrayList<ContactInfo>();
> >
> > > Change either @Persistent to @NotPersistent and the unit test
> > > succeeds.
> >
> > > SDK: appengine-java-sdk-1.2.5
> >
> > > ****************** Stack Trace
> > > ***************************************************
> >
> > > java.lang.ClassCastException: oid is not instanceof
> > > javax.jdo.identity.ObjectIdentity
> > >        at
> roster.ContactInfo.jdoCopyKeyFieldsFromObjectId(ContactInfo.java)
> > >        at
> >
> > >
> org.datanucleus.store.mapped.mapping.PersistenceCapableMapping.setObjectAsValue
> > > (PersistenceCapableMapping.java:657)
> > >        at
> > >
> org.datanucleus.store.mapped.mapping.PersistenceCapableMapping.setObject
> > > (PersistenceCapableMapping.java:364)
> > >        at org.datanucleus.store.appengine.DatastoreRelationFieldManager
> > > $1.setObjectViaMapping(DatastoreRelationFieldManager.java:132)
> > >        at org.datanucleus.store.appengine.DatastoreRelationFieldManager
> > > $1.apply(DatastoreRelationFieldManager.java:108)
> > >        at
> >
> > >
> org.datanucleus.store.appengine.DatastoreRelationFieldManager.storeRelations
> > > (DatastoreRelationFieldManager.java:80)
> > >        at
> > > org.datanucleus.store.appengine.DatastoreFieldManager.storeRelations
> > > (DatastoreFieldManager.java:795)
> > >        at
> >
> > >
> org.datanucleus.store.appengine.DatastorePersistenceHandler.insertPostProcess
> > > (DatastorePersistenceHandler.java:288)
> > >        at
> > >
> org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObjects
> > > (DatastorePersistenceHandler.java:241)
> > >        at
> > >
> org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObject
> > > (DatastorePersistenceHandler.java:225)
> > >        at
> org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent
> > > (JDOStateManagerImpl.java:3185)
> > >        at org.datanucleus.state.JDOStateManagerImpl.makePersistent
> > > (JDOStateManagerImpl.java:3161)
> > >        at org.datanucleus.ObjectManagerImpl.persistObjectInternal
> > > (ObjectManagerImpl.java:1298)
> > >        at org.datanucleus.ObjectManagerImpl.persistObject
> > > (ObjectManagerImpl.java:1175)
> > >        at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent
> > > (JDOPersistenceManager.java:669)
> > >        at org.datanucleus.jdo.JDOPersistenceManager.makePersistent
> > > (JDOPersistenceManager.java:694)
> > >        at
> > > testing.TestContactInfo.testTwoRelationShips(TestContactInfo.java:
> > > 75)
> > >        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >        at sun.reflect.NativeMethodAccessorImpl.invoke
> > > (NativeMethodAccessorImpl.java:39)
> > >        at sun.reflect.DelegatingMethodAccessorImpl.invoke
> > > (DelegatingMethodAccessorImpl.java:25)
> > >        at java.lang.reflect.Method.invoke(Method.java:597)
> > >        at junit.framework.TestCase.runTest(TestCase.java:164)
> > >        at junit.framework.TestCase.runBare(TestCase.java:130)
> > >        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:120)
> > >        at
> > > org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run
> > > (JUnit3TestReference.java:130)
> > >        at org.eclipse.jdt.internal.junit.runner.TestExecution.run
> > > (TestExecution.java:38)
> > >        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
> > > (RemoteTestRunner.java:467)
> > >        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
> > > (RemoteTestRunner.java:683)
> > >        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
> > > (RemoteTestRunner.java:390)
> > >        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
> > > (RemoteTestRunner.java:197)
> > > *************************ContactInfo.java *************************
> > > import javax.jdo.annotations.IdGeneratorStrategy;
> > > import javax.jdo.annotations.IdentityType;
> > > import javax.jdo.annotations.PersistenceCapable;
> > > import javax.jdo.annotations.Persistent;
> > > import javax.jdo.annotations.PrimaryKey;
> >
> > > import com.google.appengine.api.datastore.Key;
> >
> > > @PersistenceCapable(identityType = IdentityType.APPLICATION)
> > > public class ContactInfo {
> >
> > >    @PrimaryKey
> > >    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > >    private Key contactInfoKey;
> > >    @Persistent
> > >    private String firstName;
> > >    @Persistent
> > >    private String lastName;
> > >    @Persistent
> > >    private String phoneNumber;
> > >    @Persistent
> > >    private String emailAddress;
> > >    public ContactInfo(String firstName, String lastName, String
> > > phoneNumbers,
> > >            String emailAddresses) {
> > >        this.firstName = firstName;
> > >        this.lastName = lastName;
> > >        this.phoneNumber = phoneNumber;
> > >        this.emailAddress = emailAddress;
> > >    }
> > >    public String getFirstName() {
> > >        return firstName;
> > >    }
> > >    public void setFirstName(String firstName) {
> > >        this.firstName = firstName;
> > >    }
> > >    public String getLastName() {
> > >        return lastName;
> > >    }
> > >    public void setLastName(String lastName) {
> > >        this.lastName = lastName;
> > >    }
> > >    public String getPhoneNumber() {
> > >        return phoneNumber;
> > >    }
> > >    public void setPhoneNumber(String phoneNumber) {
> > >        this.phoneNumber = phoneNumber;
> > >    }
> > >    public Key getContactInfoId(){
> > >        return contactInfoKey;
> > >    }}
> > > ************************* Two Relationship
> > > *******************************
> > > import java.util.ArrayList;
> > > import java.util.List;
> >
> > > import javax.jdo.annotations.IdGeneratorStrategy;
> > > import javax.jdo.annotations.IdentityType;
> > > import javax.jdo.annotations.NotPersistent;
> > > import javax.jdo.annotations.PersistenceCapable;
> > > import javax.jdo.annotations.Persistent;
> > > import javax.jdo.annotations.PrimaryKey;
> >
> > > @PersistenceCapable(identityType = IdentityType.APPLICATION)
> > > public class TwoRelationship {
> > >    @PrimaryKey
> > >    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > >    private Long id;
> >
> > >    @Persistent
> > >    private ContactInfo        manager;
> > >    @Persistent
> > >    private List<ContactInfo>  staff = new ArrayList<ContactInfo>();
> > >    public ContactInfo getManager() {
> > >        return manager;
> > >    }
> > >    public void setManager(ContactInfo manager) {
> > >        this.manager = manager;
> > >    }
> > >    public List<ContactInfo> getStaff() {
> > >        return staff;
> > >    }
> > >    public void setStaff(List<ContactInfo> staff) {
> > >        this.staff = staff;
> > >    }
> >
> > > }
> > > ************************PMF.java ***************************
> > > import javax.jdo.JDOHelper;
> > > import javax.jdo.PersistenceManagerFactory;
> >
> > > public class PMF {
> > >    private static final PersistenceManagerFactory pmfInstance =
> > >        JDOHelper.getPersistenceManagerFactory("transactions-
> > > optional");
> >
> > >    private PMF() {}
> >
> > >    public static PersistenceManagerFactory get() {
> > >        return pmfInstance;
> > >    }
> > > }
> >
> > > ************************** unit test **************************
> > >    public void testTwoRelationShips(){
> >
> > >        ContactInfo boss = new ContactInfo("Walt","Disney", "", "");
> > >        ContactInfo worker = new ContactInfo("Mickey","Mouse", "",
> > > "");
> >
> > >        TwoRelationship tester = new TwoRelationship();
> > >        tester.setManager(boss);
> > >        tester.getStaff().add(worker);
> >
> > >        PersistenceManager pm = PMF.get().getPersistenceManager();
> > >        try {
> > >            pm.makePersistent(tester);
> >
> > >        }catch(Exception e){
> > >            e.printStackTrace();
> > >        }
> > >        finally {
> > >            pm.close();
> > >        }
> > >     }
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to