public static Object copyXML(Object fromBean) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XMLEncoder out = new XMLEncoder(bos);
out.writeObject(fromBean);
out.close();
ByteArrayInputStream bis = new
ByteArrayInputStream(bos.toByteArray());
XMLDecoder in = new XMLDecoder(bis);
Object toBean = in.readObject();
in.close();
return toBean;
}
Long id = ((AEntity) entity).getEntryKey();
this.getSessionFactory().getCurrentSession().evict(entity);
flush();
Entity newEntity = (Entity) this.getSessionFactory().getCurrentSession().load(entity.getClass(), id);
flush();
Entity entityCopy = (Entity) copyXML(newEntity);
this.getSessionFactory().getCurrentSession().persist(entityCopy);