public void setIdentifierMetadata ( IdentifierMetadata identifierMetadata ) { if ( this . identifierMetadata != null ) { String format = "Class %s has at least two fields, %s and %s, marked with %s annotation. " + "Only one field can be marked as an identifier. " ; String message = String . format ( format , entityClass . getName ( ) , this . identifierMetadata . getName ( ) , identifierMetadata . getName ( ) , Identifier . class . getName ( ) ) ; throw new EntityManagerException ( message ) ; } this . identifierMetadata = identifierMetadata ; }
Sets the metadata of the identifier . An exception will be thrown if there is an IdentifierMetadata already set .