List of usage examples for javax.persistence.metamodel SingularAttribute isVersion
boolean isVersion();
From source file:cz.datalite.dao.support.JpaMetamodelEntityInformation.java
/** * Returns the version attribute of the given {@link javax.persistence.metamodel.ManagedType} or {@literal null} if none available. * /*from w w w .ja va 2 s.c o m*/ * @param type must not be {@literal null}. * @return */ private static <T> SingularAttribute<? super T, ?> findVersionAttribute(ManagedType<T> type) { Set<SingularAttribute<? super T, ?>> attributes = type.getSingularAttributes(); for (SingularAttribute<? super T, ?> attribute : attributes) { if (attribute.isVersion()) { return attribute; } } return null; }
From source file:org.querybyexample.jpa.GenericRepository.java
/** * _HACK_ too bad that JPA does not provide this entityType.getVersion(); * * @see/* www . j ava 2s . c om*/ * http://stackoverflow.com/questions/13265094/generic-way-to-get-jpa-entity-version */ private SingularAttribute<? super E, ?> getVersionAttribute(EntityType<E> entityType) { for (SingularAttribute<? super E, ?> sa : entityType.getSingularAttributes()) { if (sa.isVersion()) { return sa; } } return null; }