*
* @return the {@link EntityKeyMetadata} of the entity type selected by this query or {@code null} in case this
* query does not select exactly one entity type (e.g. in case of scalar values or joins (if supported in future revisions)).
*/
public EntityKeyMetadata getSingleEntityKeyMetadataOrNull() {
EntityKeyMetadata metadata = null;
for ( Return queryReturn : getCustomQueryReturns() ) {
if ( queryReturn instanceof RootReturn ) {
if ( metadata != null ) {
return null;
}
RootReturn rootReturn = (RootReturn) queryReturn;
OgmEntityPersister persister = (OgmEntityPersister) sessionFactory.getEntityPersister( rootReturn.getEntityName() );
metadata = new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
}
}
return metadata;
}