A single Java class may be mapped as an entity multiple times, with each mapping distinguished by a distinct entity name. This is not currently possible using annotations, but it may be achieved using XML-based mappings. If a class is mapped multiple times, Hibernate needs a way to determine which entity is represented by a given instance of the class. There are two ways to provide this information:
Session, for
example, by calling Session#persist(String, Object), but this can
be verbose and lacking in typesafety, or
EntityNameResolver which is capable of extracting the information
from the entity instance.
org.hibernate.boot.SessionFactoryBuilder#addEntityNameResolver(EntityNameResolver...) , org.hibernate.cfg.Configuration#addEntityNameResolver(EntityNameResolver)
| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: The corresponding entity name, ornull if this implementation
does not know how to perform resolution for the given entity instance.The entity instance. entity)Given an entity instance, determine its entity name. |
| resolveEntityName | back to summary |
|---|---|
| public String resolveEntityName(Object entity) Given an entity instance, determine its entity name. | |