Hi !

a call to makePersistent on my Entity does just nothing. The call returns 
the "saved" identity as expected, throwing no Exception. But the Entity is 
not saved in the datastore.

I have many other Entity types that I persist the same way, with no 
difficulties. what im I doing wring ???

Here's the method :
   
@Override

public Subscription createSubscriptionForContact(String updaterUserKey, 
String contactKey) {

 PersistenceManager pm=PMF.get().getPersistenceManager();

 Subscription newSubscription;

 try{

  newSubscription = new Subscription(updaterUserKey);

  newSubscription.setContactClientKey(contactKey);

  newSubscription.setCreationDate(new Date());

  newSubscription.setsubscriptionStatus(TRDS_CONST2.SUBSCRIPTION_STATUS_NEW
);

  newSubscription.setLastUpdateDate(new Date());

  newSubscription.setLastChangeByUserID(updaterUserKey);

  newSubscription = pm.makePersistent(newSubscription);
  //this throws a NullpointerException because the encoded String Key as not 
been populated 

  System.out.println("Wrote object in the datastore. Key=" + 
newSubscription.getKey().toString());

 }

 finally{

  pm.close();

 }

 return newSubscription;

}


And here's the class :


   @PersistenceCapable(detachable="true")

public class Subscription implements Serializable{

/**

 * 

 */

private static final long serialVersionUID = 1L;

@PrimaryKey     

@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 

@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")

private String Key;

    //@Persistent

    //@Extension(vendorName="datanucleus", key="gae.pk-id", value="true")

    //private Long KeyId;

    

@Persistent

private Date dateRDV;

// Création/update du présent objet

@Persistent 

private Date creationDate;

@Persistent 

private Date lastUpdateDate;

@Persistent 

private String lastChangeByUserID;

@Persistent 

private String contactClientKey;

@Persistent 

private String contactBillingKey;


etc...


   public Subscription(){

 totalAmount=new Long(0); 

 totalRDSRest=new Long(0);

 totalGotBeforeJumpDate=new Long(0);

 totalDueAmount=new Long(0);

 totalAccount=new Long(0);

 reductionGROUPValue=new Long(0);

 bonCadeauPCFValue=new Long(0);

 bonCadeauUBIValue=new Long(0);

 bonCadeauGESValue=new Long(0);

 reductionPAFValue=new Long(0);

 reductionHEHValue=new Long(0);

 reductionOTHERValue=new Long(0);

 reductionTAJValue=new Long(0);

}

 public Subscription(String lastChangeByUserId) {

 Date now = new Date();

 this.creationDate = now;

 this.lastUpdateDate = now;

 this.lastChangeByUserID=lastChangeByUserId;

}

 //

// Calculation methods

//

//Updates totalDue and RDS rest regarding the state of the object.

public void calculateBilling(){

 long totalDue = this.getTotalAmount()

  +this.getBonCadeauPCFValue()

  +this.getBonCadeauUBIValue()

  +this.getBonCadeauGESValue()

  +this.getReductionPAFValue()

  +this.getReductionHEHValue()

  +this.getReductionTAJValue()

  +this.getReductionGROUPValue()

  +this.getReductionOTHERValue();

 this.setTotalDueAmount(totalDue);

 long newRDSRest=totalDue-this.getTotalGotBeforeJumpDate();

 this.setTotalRDSRest(newRDSRest);

}

 public String getKey() {

 return Key;

}

 public void setKey(String key) {

 this.Key = key;

}

 public Date getDateRDV() {

 return dateRDV;

}


 public void setDateRDV(Date date) {

 this.dateRDV = date;

}


 public Date getCreationDate() {

 return creationDate;

}


 public void setCreationDate(Date creationDate) {

 this.creationDate = creationDate;

}


 public Date getLastUpdateDate() {

 return lastUpdateDate;

}


 public void setLastUpdateDate(Date lastUpdateDate) {

 this.lastUpdateDate = lastUpdateDate;

}


etc...


}



Thank you for your help !!!

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