|
6 | 6 | import org.hibernate.Session; |
7 | 7 | import org.hibernate.SessionFactory; |
8 | 8 | import org.hibernate.engine.spi.SessionFactoryImplementor; |
9 | | -import org.hibernate.persister.collection.CollectionPersister; |
10 | | -import org.hibernate.persister.entity.EntityPersister; |
| 9 | +import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl; |
11 | 10 | import org.hibernate.tool.orm.jbt.api.wrp.ClassMetadataWrapper; |
12 | 11 | import org.hibernate.tool.orm.jbt.api.wrp.CollectionMetadataWrapper; |
13 | 12 | import org.hibernate.tool.orm.jbt.api.wrp.SessionFactoryWrapper; |
@@ -42,20 +41,20 @@ public void close() { |
42 | 41 |
|
43 | 42 | @Override |
44 | 43 | public Map<String, ClassMetadataWrapper> getAllClassMetadata() { |
45 | | - Map<String, EntityPersister> origin = ((SessionFactoryImplementor)sessionFactory).getMetamodel().entityPersisters(); |
46 | | - Map<String, ClassMetadataWrapper> result = new HashMap<String, ClassMetadataWrapper>(origin.size()); |
47 | | - for (String key : origin.keySet()) { |
48 | | - result.put(key, ClassMetadataWrapperFactory.createClassMetadataWrapper(origin.get(key))); |
| 44 | + Map<String, ClassMetadataWrapper> result = new HashMap<String, ClassMetadataWrapper>(); |
| 45 | + MappingMetamodelImpl mappingMetaModel = (MappingMetamodelImpl)((SessionFactoryImplementor)sessionFactory).getMappingMetamodel(); |
| 46 | + for (String key : mappingMetaModel.getAllEntityNames()) { |
| 47 | + result.put(key, ClassMetadataWrapperFactory.createClassMetadataWrapper(mappingMetaModel.entityPersister(key))); |
49 | 48 | } |
50 | 49 | return result; |
51 | 50 | } |
52 | 51 |
|
53 | 52 | @Override |
54 | 53 | public Map<String, CollectionMetadataWrapper> getAllCollectionMetadata() { |
55 | | - Map<String, CollectionPersister> origin = ((SessionFactoryImplementor)sessionFactory).getMetamodel().collectionPersisters(); |
56 | | - Map<String, CollectionMetadataWrapper> result = new HashMap<String, CollectionMetadataWrapper>(origin.size()); |
57 | | - for (String key : origin.keySet()) { |
58 | | - result.put(key, CollectionMetadataWrapperFactory.createCollectionMetadataWrapper(origin.get(key))); |
| 54 | + Map<String, CollectionMetadataWrapper> result = new HashMap<String, CollectionMetadataWrapper>(); |
| 55 | + MappingMetamodelImpl mappingMetaModel = (MappingMetamodelImpl)((SessionFactoryImplementor)sessionFactory).getMappingMetamodel(); |
| 56 | + for (String key : mappingMetaModel.getAllCollectionRoles()) { |
| 57 | + result.put(key, CollectionMetadataWrapperFactory.createCollectionMetadataWrapper(mappingMetaModel.collectionPersister(key))); |
59 | 58 | } |
60 | 59 | return result; |
61 | 60 | } |
|
0 commit comments