Search in sources :

Example 1 with CallbackType

use of org.hibernate.jpa.event.spi.CallbackType in project hibernate-orm by hibernate.

the class CallbackBuilderLegacyImpl method buildCallbacksForEntity.

@Override
public void buildCallbacksForEntity(String entityClassName, CallbackRegistrar callbackRegistrar) {
    try {
        final XClass entityXClass = reflectionManager.classForName(entityClassName);
        final Class entityClass = reflectionManager.toClass(entityXClass);
        for (CallbackType callbackType : CallbackType.values()) {
            if (callbackRegistrar.hasRegisteredCallbacks(entityClass, callbackType)) {
                // this most likely means we have a class mapped multiple times using the hbm.xml
                // "entity name" feature
                log.debugf("CallbackRegistry reported that Class [%s] already had %s callbacks registered; " + "assuming this means the class was mapped twice " + "(using hbm.xml entity-name support) - skipping subsequent registrations", entityClassName, callbackType.getCallbackAnnotation().getSimpleName());
                continue;
            }
            final Callback[] callbacks = resolveCallbacks(entityXClass, callbackType, reflectionManager);
            callbackRegistrar.registerCallbacks(entityClass, callbacks);
        }
    } catch (ClassLoadingException e) {
        throw new MappingException("entity class not found: " + entityClassName, e);
    }
}
Also used : Callback(org.hibernate.jpa.event.spi.Callback) CallbackType(org.hibernate.jpa.event.spi.CallbackType) ClassLoadingException(org.hibernate.annotations.common.reflection.ClassLoadingException) XClass(org.hibernate.annotations.common.reflection.XClass) XClass(org.hibernate.annotations.common.reflection.XClass) MappingException(org.hibernate.MappingException)

Aggregations

MappingException (org.hibernate.MappingException)1 ClassLoadingException (org.hibernate.annotations.common.reflection.ClassLoadingException)1 XClass (org.hibernate.annotations.common.reflection.XClass)1 Callback (org.hibernate.jpa.event.spi.Callback)1 CallbackType (org.hibernate.jpa.event.spi.CallbackType)1