use of org.hibernate.metadata.ClassMetadata in project BroadleafCommerce by BroadleafCommerce.
the class DynamicDaoHelperImpl method getPropertyTypes.
@Override
public List<Type> getPropertyTypes(Class<?> entityClass, HibernateEntityManager entityManager) {
entityClass = getNonProxyImplementationClassIfNecessary(entityClass);
ClassMetadata metadata = getSessionFactory(entityManager).getClassMetadata(entityClass);
List<Type> propertyTypes = new ArrayList<>();
Collections.addAll(propertyTypes, metadata.getPropertyTypes());
return propertyTypes;
}
use of org.hibernate.metadata.ClassMetadata in project BroadleafCommerce by BroadleafCommerce.
the class DynamicDaoHelperImpl method getIdField.
@Override
public Field getIdField(Class<?> clazz, Session session) {
clazz = getNonProxyImplementationClassIfNecessary(clazz);
ClassMetadata metadata = session.getSessionFactory().getClassMetadata(clazz);
Field idField = ReflectionUtils.findField(clazz, metadata.getIdentifierPropertyName());
idField.setAccessible(true);
return idField;
}
use of org.hibernate.metadata.ClassMetadata in project BroadleafCommerce by BroadleafCommerce.
the class DynamicDaoHelperImpl method getIdMetadata.
@Override
public Map<String, Object> getIdMetadata(Class<?> entityClass, HibernateEntityManager entityManager) {
entityClass = getNonProxyImplementationClassIfNecessary(entityClass);
Map<String, Object> response = new HashMap<>();
SessionFactory sessionFactory = entityManager.getSession().getSessionFactory();
ClassMetadata metadata = sessionFactory.getClassMetadata(entityClass);
if (metadata == null) {
return null;
}
String idProperty = metadata.getIdentifierPropertyName();
response.put("name", idProperty);
Type idType = metadata.getIdentifierType();
response.put("type", idType);
return response;
}
use of org.hibernate.metadata.ClassMetadata 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);
assertSame(classMetadata, ((IFacade) facade).getTarget());
}
use of org.hibernate.metadata.ClassMetadata 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);
assertSame(classMetadata, ((IFacade) facade).getTarget());
}
Aggregations