private static VariableEffectDefinition toBean(VariableEffectDefinitionJDO jdo) {
   if (jdo == null) return null;
   VariableEffectDefinition bean = new VariableEffectDefinition();
   bean.setGameId(jdo.getGameId());
   bean.setName(jdo.getName());
   bean.setId(jdo.getIdentifier());
   bean.setEffectValue(jdo.getEffectValue());
   bean.setEffectType(jdo.getEffectType());
   bean.setEffectCount(jdo.getEffectCount());
   try {
     if (jdo.getDependsOn() != null) {
       JsonBeanDeserializer jbd = new JsonBeanDeserializer(jdo.getDependsOn().getValue());
       bean.setDependsOn((Dependency) jbd.deserialize(Dependency.class));
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return bean;
 }
  public static VariableEffectDefinition createVariableDefinition(
      VariableEffectDefinition variableDefinition) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    VariableEffectDefinitionJDO variableEffectDefinitionJDO = new VariableEffectDefinitionJDO();
    variableEffectDefinitionJDO.setName(variableDefinition.getName());
    variableEffectDefinitionJDO.setGameId(variableDefinition.getGameId());
    variableEffectDefinitionJDO.setEffectValue(variableDefinition.getEffectValue());
    variableEffectDefinitionJDO.setEffectType(variableDefinition.getEffectType());
    if (variableDefinition.getEffectCount() == null) variableDefinition.setEffectCount(1);
    variableEffectDefinitionJDO.setEffectCount(variableDefinition.getEffectCount());
    if (variableDefinition.getId() != null)
      variableEffectDefinitionJDO.setIdentifier(variableDefinition.getId());
    JsonBeanSerialiser jbs = new JsonBeanSerialiser(variableDefinition.getDependsOn());
    if (variableDefinition.getDependsOn() != null)
      variableEffectDefinitionJDO.setDependsOn(new Text(jbs.serialiseToJson().toString()));

    try {
      pm.makePersistent(variableEffectDefinitionJDO);
      return toBean(variableEffectDefinitionJDO);
    } finally {
      pm.close();
    }
  }