use of org.jboss.tools.hibernate.runtime.spi.IClassMetadata in project jbosstools-hibernate by jbosstools.
the class HSearchServiceImpl method getIndexedTypes.
@Override
public Set<Class<?>> getIndexedTypes(ISessionFactory sessionFactory) {
Map<String, IClassMetadata> meta = sessionFactory.getAllClassMetadata();
Set<Class<?>> entities = new HashSet<Class<?>>();
for (String entity : new TreeSet<String>(meta.keySet())) {
Class<?> entityClass = meta.get(entity).getMappedClass();
Annotation[] annotations = entityClass.getAnnotations();
for (Annotation annotation : annotations) {
if (Indexed.class.isAssignableFrom(annotation.annotationType())) {
entities.add(entityClass);
break;
}
}
}
return entities;
}
use of org.jboss.tools.hibernate.runtime.spi.IClassMetadata in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeImpl method initializeAllClassMetadata.
@Override
protected void initializeAllClassMetadata() {
SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getTarget();
MetamodelImplementor metamodel = sessionFactory.getMetamodel();
Map<String, EntityPersister> entityPersisters = metamodel.entityPersisters();
allClassMetadata = new HashMap<String, IClassMetadata>(entityPersisters.size());
for (Entry<String, EntityPersister> entry : entityPersisters.entrySet()) {
allClassMetadata.put((String) entry.getKey(), getFacadeFactory().createClassMetadata(entry.getValue()));
}
}
use of org.jboss.tools.hibernate.runtime.spi.IClassMetadata in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeImpl method initializeAllClassMetadata.
@Override
protected void initializeAllClassMetadata() {
SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getTarget();
MetamodelImplementor metamodel = sessionFactory.getMetamodel();
Map<String, EntityPersister> entityPersisters = metamodel.entityPersisters();
allClassMetadata = new HashMap<String, IClassMetadata>(entityPersisters.size());
for (Entry<String, EntityPersister> entry : entityPersisters.entrySet()) {
allClassMetadata.put((String) entry.getKey(), getFacadeFactory().createClassMetadata(entry.getValue()));
}
}
use of org.jboss.tools.hibernate.runtime.spi.IClassMetadata in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateClassMetadata.
@Test
public void testCreateClassMetadata() {
ClassMetadata classMetadata = (ClassMetadata) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { ClassMetadata.class }, new TestInvocationHandler());
IClassMetadata facade = facadeFactory.createClassMetadata(classMetadata);
Assert.assertSame(classMetadata, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.IClassMetadata in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testGetAllClassMetadata.
@Test
public void testGetAllClassMetadata() throws Exception {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory();
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Assert.assertTrue(sessionFactoryFacade.getAllClassMetadata().isEmpty());
sessionFactory.close();
configuration.addClass(Foo.class);
sessionFactory = configuration.buildSessionFactory();
sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Map<String, IClassMetadata> allClassMetaData = sessionFactoryFacade.getAllClassMetadata();
Assert.assertNotNull(allClassMetaData.get("org.jboss.tools.hibernate.runtime.v_3_5.internal.test.Foo"));
}
Aggregations