use of org.hibernate.cfg.annotations.reflection.XMLContext in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReaderTest method testMappedSuperclassAnnotations.
@Test
public void testMappedSuperclassAnnotations() throws Exception {
XMLContext context = buildContext("org/hibernate/test/annotations/reflection/metadata-complete.xml");
JPAOverriddenAnnotationReader reader = new JPAOverriddenAnnotationReader(Organization.class, context, BootstrapContextImpl.INSTANCE);
assertTrue(reader.isAnnotationPresent(MappedSuperclass.class));
}
use of org.hibernate.cfg.annotations.reflection.XMLContext in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReaderTest method testElementCollectionConverter.
@Test
@TestForIssue(jiraKey = "HHH-11924")
public void testElementCollectionConverter() throws Exception {
XMLContext context = buildContext("org/hibernate/test/annotations/reflection/orm.xml");
Field field = Company.class.getDeclaredField("organizations");
JPAOverriddenAnnotationReader reader = new JPAOverriddenAnnotationReader(field, context, BootstrapContextImpl.INSTANCE);
assertNotNull(reader.getAnnotation(ElementCollection.class));
assertNotNull(reader.getAnnotation(Converts.class));
assertNotNull(reader.getAnnotation(Converts.class).value());
assertTrue(reader.getAnnotation(Converts.class).value().length == 1);
assertEquals(OrganizationConverter.class, reader.getAnnotation(Converts.class).value()[0].converter());
}
use of org.hibernate.cfg.annotations.reflection.XMLContext in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReaderTest method testVersionRelatedAnnotations.
@Test
public void testVersionRelatedAnnotations() throws Exception {
XMLContext context = buildContext("org/hibernate/test/annotations/reflection/orm.xml");
Method method = Administration.class.getDeclaredMethod("getVersion");
JPAOverriddenAnnotationReader reader = new JPAOverriddenAnnotationReader(method, context, BootstrapContextImpl.INSTANCE);
assertNotNull(reader.getAnnotation(Version.class));
Field field = Match.class.getDeclaredField("version");
assertNotNull(reader.getAnnotation(Version.class));
}
use of org.hibernate.cfg.annotations.reflection.XMLContext in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReaderTest method testEntityListeners.
@Test
public void testEntityListeners() throws Exception {
XMLContext context = buildContext("org/hibernate/test/annotations/reflection/orm.xml");
Method method = Administration.class.getDeclaredMethod("calculate");
JPAOverriddenAnnotationReader reader = new JPAOverriddenAnnotationReader(method, context, BootstrapContextImpl.INSTANCE);
assertTrue(reader.isAnnotationPresent(PrePersist.class));
reader = new JPAOverriddenAnnotationReader(Administration.class, context, BootstrapContextImpl.INSTANCE);
assertTrue(reader.isAnnotationPresent(EntityListeners.class));
assertEquals(1, reader.getAnnotation(EntityListeners.class).value().length);
assertEquals(LogListener.class, reader.getAnnotation(EntityListeners.class).value()[0]);
method = LogListener.class.getDeclaredMethod("noLog", Object.class);
reader = new JPAOverriddenAnnotationReader(method, context, BootstrapContextImpl.INSTANCE);
assertTrue(reader.isAnnotationPresent(PostLoad.class));
method = LogListener.class.getDeclaredMethod("log", Object.class);
reader = new JPAOverriddenAnnotationReader(method, context, BootstrapContextImpl.INSTANCE);
assertTrue(reader.isAnnotationPresent(PrePersist.class));
assertFalse(reader.isAnnotationPresent(PostPersist.class));
assertEquals(1, context.getDefaultEntityListeners().size());
assertEquals(OtherLogListener.class.getName(), context.getDefaultEntityListeners().get(0));
}
use of org.hibernate.cfg.annotations.reflection.XMLContext in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReaderTest method testBasicRelatedAnnotations.
@Test
public void testBasicRelatedAnnotations() throws Exception {
XMLContext context = buildContext("org/hibernate/test/annotations/reflection/metadata-complete.xml");
Field field = BusTrip.class.getDeclaredField("status");
JPAOverriddenAnnotationReader reader = new JPAOverriddenAnnotationReader(field, context, BootstrapContextImpl.INSTANCE);
assertNotNull(reader.getAnnotation(Enumerated.class));
assertEquals(EnumType.STRING, reader.getAnnotation(Enumerated.class).value());
assertEquals(false, reader.getAnnotation(Basic.class).optional());
field = BusTrip.class.getDeclaredField("serial");
reader = new JPAOverriddenAnnotationReader(field, context, BootstrapContextImpl.INSTANCE);
assertNotNull(reader.getAnnotation(Lob.class));
assertEquals("serialbytes", reader.getAnnotation(Columns.class).columns()[0].name());
field = BusTrip.class.getDeclaredField("terminusTime");
reader = new JPAOverriddenAnnotationReader(field, context, BootstrapContextImpl.INSTANCE);
assertNotNull(reader.getAnnotation(Temporal.class));
assertEquals(TemporalType.TIMESTAMP, reader.getAnnotation(Temporal.class).value());
assertEquals(FetchType.LAZY, reader.getAnnotation(Basic.class).fetch());
field = BusTripPk.class.getDeclaredField("busDriver");
reader = new JPAOverriddenAnnotationReader(field, context, BootstrapContextImpl.INSTANCE);
assertNotNull(reader.isAnnotationPresent(Basic.class));
}
Aggregations