@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); } }
@Override public void delete(KeyValueEntity entity) { delete(entity.getUuid()); }
@Override @Transactional public void update(KeyValueEntity entity) { delete(entity.getUuid()); persist(entity); }