List of usage examples for javax.persistence.metamodel EntityType hasVersionAttribute
boolean hasVersionAttribute();
From source file:org.querybyexample.jpa.GenericRepository.java
/** * Return the optimistic version value, if any. *///from w w w . ja va 2 s . c o m @SuppressWarnings("unchecked") @Transactional(readOnly = true) public Comparable<Object> getVersion(E entity) { EntityType<E> entityType = entityManager.getMetamodel().entity(type); if (!entityType.hasVersionAttribute()) { return null; } return (Comparable<Object>) JpaUtil.getValue(entity, getVersionAttribute(entityType)); }