Example usage for javax.persistence.metamodel EntityType getVersion

List of usage examples for javax.persistence.metamodel EntityType getVersion

Introduction

In this page you can find the example usage for javax.persistence.metamodel EntityType getVersion.

Prototype

<Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type);

Source Link

Document

Return the attribute that corresponds to the version attribute of the entity or mapped superclass.

Usage

From source file:com.github.gekoh.yagen.util.MappingUtils.java

public static String getVersionFieldName(EntityManagerFactory emf, Class entityClass) {
    EntityType entityType = emf.getMetamodel().entity(entityClass);
    SingularAttribute version;// w w  w . ja  va2 s. c o  m
    if (entityType != null && (version = entityType.getVersion(Long.class)) != null) {
        return version.getName();
    }
    return null;
}