[appengine-java] Re: owned relationship ? - could it be a bug
Hmm... If JDO does not allow unowned relationships, then when you are trying to persist B inside A, then trying to persist B by itself, are you not declaring that B is actually unowned? In this case, A can not actually hold onto B directly and can only hold its Key instead. When I read the documentation, I understood owned relationships as an Object (e.g. B) is always found in another object (e.g. A) and never by itself. Do you think that could be it? Although its weird that the 2nd transaction works when you move it around. Does it actually store two different Bs? These are all ideas. Not sure honestly... On Feb 21, 10:24 pm, aswath satrasala aswath.satras...@gmail.com wrote: Hello Payam Thanks for looking into this. Please see inline On Sun, Feb 21, 2010 at 3:25 PM, Payam pmoghad...@gmail.com wrote: Hello Aswath, What you are doing seems really odd to me. From my understanding a Datastore Key consists of multiple components. A complete key includes several pieces of information, including the application ID, the kind, and an entity ID - GAE Docs If you use encoded key strings, you can get access to these other pieces of information: @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName=datanucleus, key=gae.encoded-pk, value=true) private String encodedKey; @Persistent @Extension(vendorName=datanucleus, key=gae.pk-name, value=true) private String keyName; @Persistent @Extension(vendorName=datanucleus, key=gae.pk-id, value=true) private Long keyId; In this case, you have access to the name ID (keyName) and numeric ID (keyID) of the encoded key. Therefore, from my understanding, you can not change the name ID after you have persisted your first object. The first object determines the name ID for all remaining objects (from my understanding). This is why when you try to change it for the second object, you get an exception. Your understanding is not documented. Please see 'encodedStrings' inhttp://code.google.com/appengine/docs/java/datastore/creatinggettinga Perhaps, you can better explain why you are using the gae.pk-name extension for the name. The context of your code is not clear! When using encoded key strings, you can provide access to an object's string or numeric ID with an additional field: I am using the gae-pk-name, so that I can identity the entity uniquely. - if it is associated with a parent, I do, KeyFactory.createKey (parentkey, kind, name) and then access the entity. - if it is not associated with the parent, I do KeyFactory.createKey(kind, name) and then access the entity. I use this entity to store default values for the entity in my application. Thanks, -Aswath Thanks! On Feb 16, 11:38 pm, aswath satrasala aswath.satras...@gmail.com wrote: any help on this please... Thanks. On Fri, Feb 12, 2010 at 3:18 PM, aswath satrasala aswath.satras...@gmail.com wrote: Hello Ikia As suggested by you in the thread 'Incorrect number of entities returned', I have attached the complete files in my previous email. Please let me know, what am I doing wrong here. Thanks -Aswath On Tue, Feb 9, 2010 at 3:06 PM, aswath satrasala aswath.satras...@gmail.com wrote: Hello Ikai, Attached is the zip file that contains three files A.java B.java BTest.java Please load in your environment and test it. Thanks. -Aswath On Fri, Feb 5, 2010 at 4:36 PM, aswath satrasala aswath.satras...@gmail.com wrote: B list is missing from class A in my previous posting. Here is the complete A class... @PersistenceCapable(identityType = IdentityType.APPLICATION) public class A { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName = datanucleus, key=gae.encoded-pk, value=true) private String id; @Persistent @Extension(vendorName = datanucleus, key=gae.pk-name, value=true) private String name; @Persistent private ListB bList ; } On Fri, Feb 5, 2010 at 4:32 PM, aswath satrasala aswath.satras...@gmail.com wrote: This is a similar posting I had posted earlier incorrect number of entities returned. Hopefully, this posting may be more clean and I will get some replies. I have two classes 1) A 2) B A is in 1 to many relationship with B @PersistenceCapable(identityType = IdentityType.APPLICATION) public class A { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName = datanucleus, key=gae.encoded-pk, value=true) private String id; @Persistent @Extension(vendorName = datanucleus, key=gae.pk-name, value=true) private String name; } @PersistenceCapable(identityType = IdentityType.APPLICATION) public
[appengine-java] Re: owned relationship ? - could it be a bug
Hello Aswath, What you are doing seems really odd to me. From my understanding a Datastore Key consists of multiple components. A complete key includes several pieces of information, including the application ID, the kind, and an entity ID - GAE Docs If you use encoded key strings, you can get access to these other pieces of information: @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName=datanucleus, key=gae.encoded-pk, value=true) private String encodedKey; @Persistent @Extension(vendorName=datanucleus, key=gae.pk-name, value=true) private String keyName; @Persistent @Extension(vendorName=datanucleus, key=gae.pk-id, value=true) private Long keyId; In this case, you have access to the name ID (keyName) and numeric ID (keyID) of the encoded key. Therefore, from my understanding, you can not change the name ID after you have persisted your first object. The first object determines the name ID for all remaining objects (from my understanding). This is why when you try to change it for the second object, you get an exception. Perhaps, you can better explain why you are using the gae.pk-name extension for the name. The context of your code is not clear! Thanks! On Feb 16, 11:38 pm, aswath satrasala aswath.satras...@gmail.com wrote: any help on this please... Thanks. On Fri, Feb 12, 2010 at 3:18 PM, aswath satrasala aswath.satras...@gmail.com wrote: Hello Ikia As suggested by you in the thread 'Incorrect number of entities returned', I have attached the complete files in my previous email. Please let me know, what am I doing wrong here. Thanks -Aswath On Tue, Feb 9, 2010 at 3:06 PM, aswath satrasala aswath.satras...@gmail.com wrote: Hello Ikai, Attached is the zip file that contains three files A.java B.java BTest.java Please load in your environment and test it. Thanks. -Aswath On Fri, Feb 5, 2010 at 4:36 PM, aswath satrasala aswath.satras...@gmail.com wrote: B list is missing from class A in my previous posting. Here is the complete A class... @PersistenceCapable(identityType = IdentityType.APPLICATION) public class A { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName = datanucleus, key=gae.encoded-pk, value=true) private String id; @Persistent @Extension(vendorName = datanucleus, key=gae.pk-name, value=true) private String name; @Persistent private ListB bList ; } On Fri, Feb 5, 2010 at 4:32 PM, aswath satrasala aswath.satras...@gmail.com wrote: This is a similar posting I had posted earlier incorrect number of entities returned. Hopefully, this posting may be more clean and I will get some replies. I have two classes 1) A 2) B A is in 1 to many relationship with B @PersistenceCapable(identityType = IdentityType.APPLICATION) public class A { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName = datanucleus, key=gae.encoded-pk, value=true) private String id; @Persistent @Extension(vendorName = datanucleus, key=gae.pk-name, value=true) private String name; } @PersistenceCapable(identityType = IdentityType.APPLICATION) public class B { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName = datanucleus, key = gae.encoded-pk, value = true) private String id; @Persistent @Extension(vendorName = datanucleus, key = gae.pk-name, value = true) private String name; } public class BTest extends JDOTestCase { public void testB() throws Exception { A a = new A(); a.setName(a); B b = new B(); b.setName(b); a.getBList().add(b); beginTxn(); pm.makePersistent(a); a = pm.getObjectById(A.class, a.getId()); assertEquals(1, a.getBList().size()); commitTxn(); B b1 = new B(); b1.setName(b1); beginTxn(); pm.makePersistent(b1); b1 = pm.getObjectById(B.class, b1.getId()); b1.getId(); commitTxn(); } } The test fails at the last line b1.getId() If any of B entity is in relation with A earlier, then another entity of B cannot be persisted by itself. If I move the 2nd transaction to the beginning, the test passes. -Aswath -- 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Class XXX has multiple relationship fields of type YYYY
The problem is still not solved. Although you can persist an object with multiple relations of the same type. When you actually query the object, the retrieved object has duplicates for the multiple relations. As in, if I were to persist instances A, B inside C. When I query for C, both objects retrieved will be A. There will be no B. This is a serious bug! On Jan 26, 4:54 pm, oth other...@gmail.com wrote: Michael, In your jdoconfig.xml file add this entry: property name=datanucleus.appengine.allowMultipleRelationsOfSameType value=true/ Thanks On Jan 26, 3:12 pm, Michael Shtelma mshte...@gmail.com wrote: Hi all, I am also experiencing this problem on GAE 1.3.0. Using multipleRelationsOfSameTypeAreErrors helps not in all cases, when I am trying to read such entities I get mentioned exception. Are the any solution for the 1.3.0 ? Thanks, Michael On Jan 21, 9:20 am, cowper iamco...@gmail.com wrote: Hi, I have a similar issue with 1.3.0 however it arises when the types are the same and not related to inheritance of any type. The work around suggested doesn't seem to work. Is the workaround valid for 1.3.0? thx, Conor On Dec 4 2009, 9:52 pm, Max Ross (Google) maxr +appeng...@google.com wrote: SDK 1.2.8 contains a new check that detects if one of your JDO or JPA model objects has two relationship fields of the same type. For example: class A { ListB bList; ListB anotherBList; } Unfortunately I was a little too aggressive with this check, so the following also run afoul of the check: abstract class B {} class C extends B {} class D extends B {} class A { ListC cList: ListD dList; } If you get an exception that says Class XXX has multiple relationship fields of type . This is not yet supported. and your class hierarchy resembles the one above, you can disable this check by with the following config property: property name=datanucleus.appengine.multipleRelationsOfSameTypeAreErrors value=true/ We'll get this fixed shortly. Sorry for the trouble, Max -- 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.