use of org.hibernate.AnnotationException in project hibernate-orm by hibernate.
the class PkDrivenByDefaultMapsIdSecondPass method doSecondPass.
public void doSecondPass(Map persistentClasses) throws MappingException {
PersistentClass referencedEntity = (PersistentClass) persistentClasses.get(referencedEntityName);
if (referencedEntity == null) {
throw new AnnotationException("Unknown entity name: " + referencedEntityName);
}
TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit(referencedEntity, referencedEntity.getKey().getColumnIterator(), columns, value);
}
use of org.hibernate.AnnotationException in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getTemporal.
private void getTemporal(List<Annotation> annotationList, Element element) {
Element subElement = element != null ? element.element("temporal") : null;
if (subElement != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(Temporal.class);
String temporal = subElement.getTextTrim();
if ("DATE".equalsIgnoreCase(temporal)) {
ad.setValue("value", TemporalType.DATE);
} else if ("TIME".equalsIgnoreCase(temporal)) {
ad.setValue("value", TemporalType.TIME);
} else if ("TIMESTAMP".equalsIgnoreCase(temporal)) {
ad.setValue("value", TemporalType.TIMESTAMP);
} else if (StringHelper.isNotEmpty(temporal)) {
throw new AnnotationException("Unknown TemporalType: " + temporal + ". " + SCHEMA_VALIDATION);
}
annotationList.add(AnnotationFactory.create(ad));
}
}
use of org.hibernate.AnnotationException in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method addTargetClass.
private void addTargetClass(Element element, AnnotationDescriptor ad, String nodeName, XMLContext.Default defaults) {
String className = element.attributeValue(nodeName);
if (className != null) {
Class clazz;
try {
clazz = classLoaderAccess.classForName(XMLContext.buildSafeClassName(className, defaults));
} catch (ClassLoadingException e) {
throw new AnnotationException("Unable to find " + element.getPath() + " " + nodeName + ": " + className, e);
}
ad.setValue(getJavaAttributeNameFromXMLOne(nodeName), clazz);
}
}
use of org.hibernate.AnnotationException in project hibernate-orm by hibernate.
the class OrmVersionTest method testInvalidOrm1.
@Test
public void testInvalidOrm1() {
PersistenceUnitInfoImpl pui = new PersistenceUnitInfoImpl("invalid-orm1-test", "1.0").addMappingFileName("org/hibernate/jpa/test/jee/invalid-orm-1.xml");
HibernatePersistenceProvider hp = new HibernatePersistenceProvider();
EntityManagerFactory emf = null;
try {
emf = hp.createContainerEntityManagerFactory(pui, Collections.EMPTY_MAP);
Assert.fail("expecting 'invalid content' error");
} catch (InvalidMappingException | AnnotationException expected) {
// expected condition
} catch (PersistenceException expected) {
// expected condition
} finally {
if (emf != null) {
emf.close();
}
}
}
use of org.hibernate.AnnotationException in project hibernate-orm by hibernate.
the class BasicHibernateAnnotationsTest method testTypeDefWithoutNameAndDefaultForTypeAttributes.
@Test
public void testTypeDefWithoutNameAndDefaultForTypeAttributes() {
SessionFactory sf = null;
StandardServiceRegistryImpl ssr = null;
try {
Configuration config = new Configuration();
config.addAnnotatedClass(LocalContactDetails.class);
ssr = ServiceRegistryBuilder.buildServiceRegistry(config.getProperties());
sf = config.buildSessionFactory(ssr);
fail("Did not throw expected exception");
} catch (AnnotationException ex) {
assertEquals("Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass org.hibernate.test.annotations.entity.PhoneNumberType", ex.getMessage());
} finally {
if (ssr != null) {
ssr.destroy();
}
if (sf != null) {
sf.close();
}
}
}
Aggregations