示例#1
0
  @Override
  @Transactional
  public void persist(KeyValueEntity entity) {
    KeyValueBinaryVO bvo = new KeyValueBinaryVO();
    bvo.setUuid(entity.getUuid());
    try {
      bvo.setContents(SerializableHelper.writeObject(entity));
    } catch (IOException e) {
      throw new CloudRuntimeException(e);
    }
    dbf.getEntityManager().persist(bvo);

    List<KeyValueStruct> structs = new KeyValueSerializer().build(entity);
    for (KeyValueStruct struct : structs) {
      KeyValueVO vo = new KeyValueVO();
      vo.setClassName(entity.getClass().getName());
      vo.setUuid(entity.getUuid());
      vo.setEntityKey(struct.getKey());
      vo.setEntityValue(struct.getValue());
      vo.setValueType(struct.getType().getName());
      dbf.getEntityManager().persist(vo);
    }
  }
示例#2
0
 @Override
 public void delete(KeyValueEntity entity) {
   delete(entity.getUuid());
 }
示例#3
0
 @Override
 @Transactional
 public void update(KeyValueEntity entity) {
   delete(entity.getUuid());
   persist(entity);
 }