@ SuppressWarnings ( "deprecation" ) // No good alternative in the Hibernate API yet protected ID extractId ( T entity ) { final Class < ? > entityClass = TypeHelper . getTypeArguments ( JpaBaseRepository . class , this . getClass ( ) ) . get ( 0 ) ; final SessionFactory sf = ( SessionFactory ) ( getEntityManager ( ) . getEntityManagerFactory ( ) ) ; final ClassMetadata cmd = sf . getClassMetadata ( entityClass ) ; final SessionImplementor si = ( SessionImplementor ) ( getEntityManager ( ) . getDelegate ( ) ) ; @ SuppressWarnings ( "unchecked" ) final ID result = ( ID ) cmd . getIdentifier ( entity , si ) ; return result ; }
Determines the ID for the entity