Search in sources :

Example 1 with JaxbIdClass

use of org.hibernate.boot.jaxb.mapping.spi.JaxbIdClass in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method getIdClass.

private IdClass getIdClass(ManagedType root, XMLContext.Default defaults) {
    JaxbIdClass element = root instanceof EntityOrMappedSuperclass ? ((EntityOrMappedSuperclass) root).getIdClass() : null;
    if (element != null) {
        String className = element.getClazz();
        if (className != null) {
            AnnotationDescriptor ad = new AnnotationDescriptor(IdClass.class);
            Class<?> clazz;
            try {
                clazz = classLoaderAccess.classForName(XMLContext.buildSafeClassName(className, defaults));
            } catch (ClassLoadingException e) {
                throw new AnnotationException("Unable to find id-class: " + className, e);
            }
            ad.setValue("value", clazz);
            return AnnotationFactory.create(ad);
        } else {
            throw new AnnotationException("id-class without class. " + SCHEMA_VALIDATION);
        }
    } else if (defaults.canUseJavaAnnotations()) {
        return getPhysicalAnnotation(IdClass.class);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) IdClass(jakarta.persistence.IdClass) JaxbIdClass(org.hibernate.boot.jaxb.mapping.spi.JaxbIdClass) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) JaxbIdClass(org.hibernate.boot.jaxb.mapping.spi.JaxbIdClass) EntityOrMappedSuperclass(org.hibernate.boot.jaxb.mapping.spi.EntityOrMappedSuperclass) AnnotationException(org.hibernate.AnnotationException)

Aggregations

IdClass (jakarta.persistence.IdClass)1 AnnotationException (org.hibernate.AnnotationException)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1 EntityOrMappedSuperclass (org.hibernate.boot.jaxb.mapping.spi.EntityOrMappedSuperclass)1 JaxbIdClass (org.hibernate.boot.jaxb.mapping.spi.JaxbIdClass)1 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)1