List of usage examples for javax.persistence.metamodel ManagedType getAttributes
Set<Attribute<? super X, ?>> getAttributes();
From source file:de.micromata.genome.jpa.metainf.MetaInfoUtils.java
/** * To entity meta data./* www . j a v a 2s. c o m*/ * * @param mt the mt * @return the entity metadata */ private static EntityMetadata toEntityMetaData(ManagedType<?> mt) { EntityMetadataBean ret = new EntityMetadataBean(); ret.setJavaType(mt.getJavaType()); if (mt instanceof EntityType) { EntityType ift = (EntityType) mt; ret.setDatabaseName(ift.getName()); } // TODO RK delete propDesc List<PropertyDescriptor> propDescs = Arrays.asList(PropertyUtils.getPropertyDescriptors(ret.getJavaType())); Set<?> attr = mt.getAttributes(); for (Object oa : attr) { Attribute<?, ?> at = (Attribute<?, ?>) oa; Optional<PropertyDescriptor> pdo = propDescs.stream().filter((el) -> el.getName().equals(at.getName())) .findFirst(); ColumnMetadata colm = getColumnMetaData(ret, mt.getJavaType(), at, pdo); if (colm != null) { ret.getColumns().put(colm.getName(), colm); } } /// EntityType.getName() is not correct. Table[] tabs = mt.getJavaType().getAnnotationsByType(Table.class); if (tabs != null && tabs.length > 0) { for (Table tab : tabs) { if (StringUtils.isNotBlank(tab.name()) == true) { ret.setDatabaseName(tab.name()); break; } } } return ret; }