Any help here...

Thanks.

On Wed, Feb 3, 2010 at 5:35 PM, aswath satrasala <[email protected]
> wrote:

> I did further investigation on my unittest (code is pasted in my previous
> email).
> The second transaction block is not persisting the SecurityGroup Entity.
> If I add the following line with in txn block,
>         securityGroup = pm.getObjectById(SecurityGroup.class,
> securityGroup.getId());
>
> I see the following in testresults file
> Testcase: testSecurityGroupNotBelongToTenant took 0.239 sec
>     Caused an ERROR
> The key value passed to construct a SingleFieldIdentity of type "class
> javax.jdo.identity.StringIdentity" for class "class
> com.veersoft.security.SecurityGroup" is null.
>
> -Aswath
>
>
> On Wed, Feb 3, 2010 at 12:11 PM, aswath satrasala <
> [email protected]> wrote:
>
>> Hello
>> Anything wrong here.
>> I have two classes Tenant and SecurityGroup.
>> * Create Tenant
>> * Create SecurityGroup
>> * Add SecurityGroup to Tenant
>> * Persist.
>>
>> * Create another SecurityGroup entity.
>> * Persist
>>
>> When I query the datastore for SecurityGroup entities, I get back one
>> entity instead of two.
>>
>> Any ideas?
>>
>> Following is the code for the two classes.
>> @PersistenceCapable(identityType = IdentityType.APPLICATION)
>> public class Tenant {
>>     @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 List<SecurityGroup> secGrpList = new
>> ArrayList<SecurityGroup>();
>> }
>>
>> @PersistenceCapable(identityType = IdentityType.APPLICATION)
>> public class SecurityGroup {
>>
>>     @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;
>> }
>>
>> Thanks
>>
>>
>>
>> On Thu, Jan 28, 2010 at 5:14 PM, aswath satrasala <
>> [email protected]> wrote:
>>
>>> I have the following unittest code.  I am persisting two SecurityGroup
>>> entities, one as a child of Tenant and one entity not having any parent.
>>>
>>>         beginTxn();
>>>         Tenant tenant = new Tenant();
>>>         SecurityGroup securityGroup = new SecurityGroup();
>>>         securityGroup.setName("PARTYMGRADMIN");
>>>         tenant.getSecGrpList().add(securityGroup);
>>>         pm.makePersistent(tenant);
>>>         commitTxn();
>>>
>>>         beginTxn();
>>>         securityGroup = new SecurityGroup();
>>>         securityGroup.setName("PARTYMGRADMIN1");
>>>         pm.makePersistent(securityGroup);
>>>         commitTxn();
>>>
>>>         beginTxn();
>>>         Query q = pm.newQuery(SecurityGroup.class);
>>>         List<SecurityGroup> results = (List<SecurityGroup>) q.execute();
>>>         assertEquals(2, results.size());
>>>         commitTxn();
>>>
>>> I get results.size() as one. I am expecting the results.size() as two
>>>
>>> -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 [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