public < T > Key < T > getKey ( final T entity ) { T unwrapped = entity ; if ( unwrapped instanceof ProxiedEntityReference ) { final ProxiedEntityReference proxy = ( ProxiedEntityReference ) unwrapped ; return ( Key < T > ) proxy . __getKey ( ) ; } unwrapped = ProxyHelper . unwrap ( unwrapped ) ; if ( unwrapped instanceof Key ) { return ( Key < T > ) unwrapped ; } final Object id = getId ( unwrapped ) ; final Class < T > aClass = ( Class < T > ) unwrapped . getClass ( ) ; return id == null ? null : new Key < T > ( aClass , getCollectionName ( aClass ) , id ) ; }
Gets the Key for an entity