While persisting following entity I am getting a server error : null in GWT 
development console. But on removing the call to pm.persist() everything 
goes right. I have doubts that I have not defined this entity properly. 
Maybe I am using types not supported by Datastore.Or is there anything else 
I am doing wrong? Please please help it's been a week I am following this 
long chain of exceptions with this GWT project.


package com.torrid.gwt.pollingApp.server;


import com.google.appengine.api.datastore.Key;

import javax.jdo.annotations.EmbeddedOnly;
import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.Version;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.VersionStrategy;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.PersistenceManager;
import javax.jdo.JDOHelper;
import javax.jdo.Query;
import com.torrid.gwt.pollingApp.server.PMF;

import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

@PersistenceCapable
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="VERSION",
         extensions={@Extension(vendorName="datanucleus", key="field-name", 
value="myVersion")})
public class User{
 @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
    
    protected Long version;
@Persistent
private String name;
 @Persistent
@Embedded
private Password kunji;
    public void setName(String name){
this.name=name;
}
public void setPassword(String pass){
byte[] bSalt;
String salt = null;
String hash = null;
try{
bSalt = PassEncryptionService.generateSalt();
salt = new String(bSalt);
hash = new String(PassEncryptionService.getEncryptedPassword(pass,bSalt));
}
catch(NoSuchAlgorithmException e){
//no idea about what to do yet.
}
catch(InvalidKeySpecException e){
//no idea about what to do yet.
}
kunji=new Password(hash,salt);
}
public String getPassword(){
return "abc";
}
    public String getName(){
return this.name;
}
public Long getId(){
return this.id;
}
 @PersistenceCapable
@EmbeddedOnly
public static class Password{
@Persistent
private String hash;
 @Persistent
private String salt;
 public Password(String hash,String salt){
this.hash=hash; this.salt=salt;
}
 }
public static User findUser(Long id){
if(id==null)
return null;
PersistenceManager pm = PMF.getInstance().getPersistenceManager();
return pm.getObjectById(User.class,id);
}
 public Long getVersion(){
return this.version;
}
 public void persist(){
PersistenceManager pm  = PMF.getInstance().getPersistenceManager();
try{
pm.makePersistent(this);
}
finally{
pm.close();
}
}
 }


package com.torrid.gwt.pollingApp.server;
import javax.jdo.JDOHelper;import javax.jdo.PersistenceManagerFactory;
public final class PMF {
  private static final PersistenceManagerFactory pmfInstance =
    JDOHelper.getPersistenceManagerFactory("transactions-optional");

 private PMF() {}

 public static PersistenceManagerFactory getInstance() {
    return pmfInstance;
 }}


public void persist(){
    PersistenceManager pm  = PMF.getInstance().getPersistenceManager();
    try{
        pm.makePersistent(this);
    }
    finally{
        pm.close();
    }}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to