// The method that do not work :

@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);
			
			// The next line throws no Exception, but the Entity is not persisted
			newSubscription = pm.makePersistent(newSubscription);
			// The next Line throws NullPointerException, because the String Key in the object has not been populated and is still null (should not..)
			// I checked in the data sore browser, it's true. The entity is not saved.
			System.out.println("Wrote object in the datastore. Key=" + newSubscription.getKey().toString());
		}
		finally{
			pm.close();
		}
		return newSubscription;
	}

// My "Subscription" class :

package com.on.trds.client.calendar.RPC;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Extension;

@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;
	
	@Persistent 
	private String jumpDateKey;
	
	@Persistent 
	private String groupSubscriptionKey;
	
	@Persistent
	private String blockKey;
	
	@Persistent 
	private Boolean hasChildSubscriptions=false;
	@Persistent 
	private Short subscriptionStatus = 0;

	@Persistent 
	private Long totalAmount;
	@Persistent 
	private Long totalDueAmount;
	@Persistent 
	private Long totalAccount;
	@Persistent 
	private Long totalGotBeforeJumpDate;
	@Persistent 
	private Long totalRDSRest;
	@Persistent 
	private Boolean paysAccount;
	@Persistent 
	private Boolean performsBankWiring;
	@Persistent 
	private Boolean performsPostWiring;
	@Persistent 
	private Boolean wiringOK;
	@Persistent 
	private Boolean paymentOK;
	@Persistent 
	private Date postWiringPapersSentDate;
	@Persistent 
	private Date confirmationEmailSentDate;
	@Persistent 
	private String bonCadeauPCFRemark;
	@Persistent 
	private Long bonCadeauPCFValue;
	@Persistent
	private String bonCadeauUBIRemark;
	@Persistent 
	private Long bonCadeauUBIValue;
	@Persistent 
	private String bonCadeauGESRemark;
	@Persistent 
	private Long bonCadeauGESValue;
	@Persistent 
	private String reductionPAFRemark;
	@Persistent 
	private Long reductionPAFValue;
	@Persistent 
	private String reductionHEHRemark;
	@Persistent 
	private Long reductionHEHValue;
	@Persistent 
	private String reductionTAJRemark;
	@Persistent 
	private Long reductionTAJValue;
	@Persistent 
	private String reductionGROUPRemark;
	@Persistent 
	private Long reductionGROUPValue;
	@Persistent 
	private String reductionOTHERRemark;
	@Persistent 
	private Long reductionOTHERValue;
	
	@Persistent 
	private Short reservationType;
	@Persistent 
	private Boolean video;
	@Persistent 
	private String remarks;
	
	@Persistent 
	private Boolean Controlling_minAge;
	@Persistent 
	private Boolean Controlling_minWeight;
	@Persistent 
	private Boolean Controlling_maxWeight;
	@Persistent 
	private Boolean Controlling_confirmMailSent;
	@Persistent 
	private Date Controlling_confirmMailSentDate;
	@Persistent 
	private String Controlling_confirmMailContent;
	@Persistent 
	private Boolean Controlling_mineurs;
	@Persistent 
	private Boolean Controlling_billingOK;
	@Persistent 
	private Boolean Controlling_jumpDone;	

	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;
	}

	//Updates totalDue and RDS rest
	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;
	}

	public String getLastChangeByUserID() {
		return lastChangeByUserID;
	}

	public void setLastChangeByUserID(String lastChangeByUserID) {
		this.lastChangeByUserID = lastChangeByUserID;
	}

	public void setContactClientKey(String contactClientKey) {
		this.contactClientKey = contactClientKey;
	}

	public String getContactClientKey() {
		return contactClientKey;
	}

	public void setContactBillingKey(String contactBillingKey) {
		this.contactBillingKey = contactBillingKey;
	}

	public String getContactBillingKey() {
		return contactBillingKey;
	}

	public String getJumpDateKey() {
		return jumpDateKey;
	}
	
	public void setJumpDateKey(String jumpDateKey) {
		this.jumpDateKey = jumpDateKey;
	}

	public void setGroupSubscriptionKey(String groupSubscriptionKey) {
		this.groupSubscriptionKey = groupSubscriptionKey;
	}

	public String getGroupSubscriptionKey() {
		return groupSubscriptionKey;
	}

	public void setBlockKey(String blockKey) {
		this.blockKey = blockKey;
	}

	public String getBlockKey() {
		return blockKey;
	}

	public void setHasChildSubscriptions(boolean hasChildSubscriptions) {
		this.hasChildSubscriptions = hasChildSubscriptions;
	}

	public boolean hasChildSubscriptions() {
		return hasChildSubscriptions;
	}

	public short getsubscriptionStatus() {
		return subscriptionStatus;
	}

	public void setsubscriptionStatus(short status) {
		this.subscriptionStatus = status;
	}

	public Long getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(Long totalAmount) {
		this.totalAmount = totalAmount;
	}

	public String getBonCadeauPCFRemark() {
		return bonCadeauPCFRemark;
	}

	public void setBonCadeauPCFRemark(String bonCadeauPCFRemark) {
		this.bonCadeauPCFRemark = bonCadeauPCFRemark;
	}

	public Long getBonCadeauPCFValue() {
		return bonCadeauPCFValue;
	}

	public void setBonCadeauPCFValue(Long bonCadeauPCFValue) {
		this.bonCadeauPCFValue = bonCadeauPCFValue;
	}

	public String getBonCadeauUBIRemark() {
		return bonCadeauUBIRemark;
	}

	public void setBonCadeauUBIRemark(String bonCadeauUBIRemark) {
		this.bonCadeauUBIRemark = bonCadeauUBIRemark;
	}

	public Long getBonCadeauUBIValue() {
		return bonCadeauUBIValue;
	}

	public void setBonCadeauUBIValue(Long bonCadeauUBIValue) {
		this.bonCadeauUBIValue = bonCadeauUBIValue;
	}

	public String getBonCadeauGESRemark() {
		return bonCadeauGESRemark;
	}

	public void setBonCadeauGESRemark(String bonCadeauGESRemark) {
		this.bonCadeauGESRemark = bonCadeauGESRemark;
	}

	public Long getBonCadeauGESValue() {
		return bonCadeauGESValue;
	}

	public void setBonCadeauGESValue(long bonCadeauGESValue) {
		this.bonCadeauGESValue = bonCadeauGESValue;
	}

	public String getReductionPAFRemark() {
		return reductionPAFRemark;
	}

	public void setReductionPAFRemark(String reductionPAFRemark) {
		this.reductionPAFRemark = reductionPAFRemark;
	}

	public Long getReductionPAFValue() {
		return reductionPAFValue;
	}

	public void setReductionPAFValue(long reductionPAFValue) {
		this.reductionPAFValue = reductionPAFValue;
	}

	public String getReductionHEHRemark() {
		return reductionHEHRemark;
	}

	public void setReductionHEHRemark(String reductionHEHRemark) {
		this.reductionHEHRemark = reductionHEHRemark;
	}

	public Long getReductionHEHValue() {
		return reductionHEHValue;
	}

	public void setReductionHEHValue(long reductionHEHValue) {
		this.reductionHEHValue = reductionHEHValue;
	}

	public String getReductionTAJRemark() {
		return reductionTAJRemark;
	}

	public void setReductionTAJRemark(String reductionTAJRemark) {
		this.reductionTAJRemark = reductionTAJRemark;
	}

	public Long getReductionTAJValue() {
		return reductionTAJValue;
	}

	public void setReductionTAJValue(long reductionTAJValue) {
		this.reductionTAJValue = reductionTAJValue;
	}

	public Long getTotalDueAmount() {
		return totalDueAmount;
	}

	public void setTotalDueAmount(Long long1) {
		this.totalDueAmount = long1;
	}
	
	public short getReservationType() {
		return reservationType;
	}

	public void setReservationType(short reservationType) {
		this.reservationType = reservationType;
	}
	
	public boolean isVideo() {
		return video;
	}

	public void setVideo(boolean video) {
		this.video = video;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarques) {
		this.remarks = remarques;
	}

/*	public void setKeyId(Long keyId) {
		this.KeyId = keyId;
	}

	public Long getKeyId() {
		return KeyId;
	}
*/
	public void setReductionGROUPRemark(String reductionGROUPRemark) {
		this.reductionGROUPRemark = reductionGROUPRemark;
	}

	public String getReductionGROUPRemark() {
		return reductionGROUPRemark;
	}

	public void setReductionGROUPValue(Long reductionGROUPValue) {
		this.reductionGROUPValue = reductionGROUPValue;
	}

	public Long getReductionGROUPValue() {
		return reductionGROUPValue;
	}

	public void setReductionOTHERRemark(String reductionOTHERRemark) {
		this.reductionOTHERRemark = reductionOTHERRemark;
	}

	public String getReductionOTHERRemark() {
		return reductionOTHERRemark;
	}

	public void setReductionOTHERValue(long reductionOTHERValue) {
		this.reductionOTHERValue = reductionOTHERValue;
	}

	public Long getReductionOTHERValue() {
		return reductionOTHERValue;
	}

	public void setTotalAccount(Long totalAccount) {
		this.totalAccount = totalAccount;
	}

	public Long getTotalAccount() {
		return totalAccount;
	}

	public void setTotalRDSRest(Long totalRDSRest) {
		this.totalRDSRest = totalRDSRest;
	}

	public Long getTotalRDSRest() {
		return totalRDSRest;
	}

	public void setPaysAccount(Boolean paysAccount) {
		this.paysAccount = paysAccount;
	}

	public Boolean getPaysAccount() {
		return paysAccount;
	}

	public void setTotalGotBeforeJumpDate(Long totalGotBeforeJumpDate) {
		this.totalGotBeforeJumpDate = totalGotBeforeJumpDate;
	}

	public Long getTotalGotBeforeJumpDate() {
		return totalGotBeforeJumpDate;
	}

	public void setPerformsBankWiring(Boolean performsBankWiring) {
		this.performsBankWiring = performsBankWiring;
	}

	public Boolean getPerformsBankWiring() {
		return performsBankWiring;
	}

	public void setPerformsPostWiring(Boolean performsPostWiring) {
		this.performsPostWiring = performsPostWiring;
	}

	public Boolean getPerformsPostWiring() {
		return performsPostWiring;
	}

	public void setPostWiringPapersSentDate(Date postWiringPapersSentDate) {
		this.postWiringPapersSentDate = postWiringPapersSentDate;
	}

	public Date getPostWiringPapersSentDate() {
		return postWiringPapersSentDate;
	}

	public void setConfirmationEmailSentDate(Date confirmationEmailSentDate) {
		this.confirmationEmailSentDate = confirmationEmailSentDate;
	}

	public Date getConfirmationEmailSentDate() {
		return confirmationEmailSentDate;
	}

	public void setControlling_confirmMailSentDate(
			Date controlling_confirmMailSentDate) {
		Controlling_confirmMailSentDate = controlling_confirmMailSentDate;
	}

	public Date getControlling_confirmMailSentDate() {
		return Controlling_confirmMailSentDate;
	}

	public void setControlling_confirmMailContent(
			String controlling_confirmMailContent) {
		Controlling_confirmMailContent = controlling_confirmMailContent;
	}

	public String getControlling_confirmMailContent() {
		return Controlling_confirmMailContent;
	}

	public void setWiringOK(Boolean wiringOK) {
		this.wiringOK = wiringOK;
	}

	public Boolean getWiringOK() {
		return wiringOK;
	}

	public void setPaymentOK(Boolean paymentOK) {
		this.paymentOK = paymentOK;
	}

	public Boolean getPaymentOK() {
		return paymentOK;
	}

	public void setControlling_minAge(Boolean controlling_minAge) {
		Controlling_minAge = controlling_minAge;
	}

	public Boolean getControlling_minAge() {
		return Controlling_minAge;
	}

	public Boolean getControlling_minWeight() {
		return Controlling_minWeight;
	}

	public void setControlling_minWeight(Boolean controlling_minWeight) {
		Controlling_minWeight = controlling_minWeight;
	}

	public Boolean getControlling_maxWeight() {
		return Controlling_maxWeight;
	}

	public void setControlling_maxWeight(Boolean controlling_maxWeight) {
		Controlling_maxWeight = controlling_maxWeight;
	}

	public Boolean getControlling_confireMailSent() {
		return Controlling_confirmMailSent;
	}

	public void setControlling_confireMailSent(Boolean controlling_confireMailSent) {
		Controlling_confirmMailSent = controlling_confireMailSent;
	}

	public Boolean getControlling_mineurs() {
		return Controlling_mineurs;
	}

	public void setControlling_mineurs(Boolean controlling_mineurs) {
		Controlling_mineurs = controlling_mineurs;
	}

	public Boolean getControlling_billingOK() {
		return Controlling_billingOK;
	}

	public void setControlling_billingOK(Boolean controlling_billingOK) {
		Controlling_billingOK = controlling_billingOK;
	}

	public void setControlling_jumpDone(Boolean controlling_jumpDone) {
		Controlling_jumpDone = controlling_jumpDone;
	}

	public Boolean getControlling_jumpDone() {
		return Controlling_jumpDone;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}