Hi,
I am new to GAE and  especially for Datastore (JDO)
 
I have an Object Composition :   User object has a reference of Contact  
object.
I am able to store them in datastore.. but with same username as primary 
key..  can someone point out where is the problem in code?
 
Here is the code snippet..
 
//User class
 
 @PersistenceCapable (identityType = IdentityType.APPLICATION)
 public class User{
 @PrimaryKey
 @Persistent (valueStrategy = IdGeneratorStrategy.IDENTITY) 
 String username;
 @Persistent
 Contact contact;
 //getters and setters
 }
 
 
// Contact  class
 
@PersistenceCapable (identityType = IdentityType.APPLICATION)
public class Contact {
@PrimaryKey    
@Persistent (valueStrategy = IdGeneratorStrategy.IDENTITY) 
private Key username; 
 
@Persistent
String Phone1;
}
 
 
 
//DAO class
public void register()  {
User user = new User();
user.setUserName("abc");
 
Contact contact=new Contact();
contact.setEmail("[email protected]");
user.setContact(contact);
pm.makePersistent(user);
}
 
 
 
If I call this register method twice ( or equivalent to submit a 
registration form  twice with same set of  username and email id !!)  ,the 
datastore is not complaining about duplicate key Exception..

Since I am creating "username" as my KEY I am expecting to get  duplicate 
key Exception. But why this is not happening?   
 
 
-thanks
Ma
 
 
 
 
 
 
 

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/ssALgOc3N4sJ.
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?hl=en.

Reply via email to