List of usage examples for org.hibernate.metadata ClassMetadata getVersion
Object getVersion(Object object) throws HibernateException;
From source file:at.molindo.esi4j.module.hibernate.HibernateEntityResolver.java
License:Apache License
/** * must be called within originating session *///w ww .j a v a 2 s . co m @Override public ObjectKey toObjectKey(Object entity) { SessionFactory factory = getSessionFactory(); Session session = getCurrentSession(factory); String entityName = _entityNames.find(entity.getClass()); ClassMetadata meta = factory.getClassMetadata(entityName); Class<?> type = meta.getMappedClass(); Serializable id = meta.getIdentifier(entity, (SessionImpl) session); Long version = toLongVersion(meta.getVersion(entity)); return new ObjectKey(type, id, version); }