Skip to content

Commit

Permalink
HBX-2390: Create a JBoss Tools adaptation layer in Hibernate Tools
Browse files Browse the repository at this point in the history
  - Refactor method 'org.hibernate.tool.orm.jbt.wrp.SessionFactoryWrapper#getAllCollectionMetadata()' to return a map of wrapped collection persisters
  - Adapt test cases 'org.hibernate.tool.orm.jbt.wrp.SessionFactoryWrapperTest#testGetAllCollectionMetadata()' and 'org.hibernate.tool.orm.jbt.wrp.SessionFactoryWrapperTest#testGetCollectionMetadata()' to the above change

Signed-off-by: Koen Aers <[email protected]>
  • Loading branch information
koentsje committed Jun 30, 2023
1 parent 0489358 commit 6770197
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public Map<String, EntityPersister> getAllClassMetadata() {
}

public Map<String, CollectionPersister> getAllCollectionMetadata() {
return getMetamodel().collectionPersisters();
Map<String, CollectionPersister> origin = getMetamodel().collectionPersisters();
Map<String, CollectionPersister> result = new HashMap<String, CollectionPersister>(origin.size());
for (String key : origin.keySet()) {
result.put(key, (CollectionPersister)CollectionPersisterWrapperFactory.create(origin.get(key)));
}
return result;
}

public EntityPersister getClassMetadata(String string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.HashSet;
import java.util.Set;

import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.spi.SessionFactoryImplementor;
Expand Down Expand Up @@ -163,12 +162,6 @@ public void testGetIdentifier() {
assertSame("bar", identifier);
}







@Test
public void testIsInstanceOfAbstractEntityPersister() throws Exception {
Object dummyEntityPersister = EntityPersisterWrapperFactory.create(createTestEntityPersister());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public void testGetAllClassMetadata() throws Exception {
public void testGetAllCollectionMetadata() throws Exception {
Map<String, CollectionPersister> allCollectionMetadata = sessionFactoryWrapper.getAllCollectionMetadata();
assertEquals(1, allCollectionMetadata.size());
assertNotNull(allCollectionMetadata.get(Foo.class.getName() + ".bars"));
CollectionPersister barsPersister = allCollectionMetadata.get(Foo.class.getName() + ".bars");
assertNotNull(barsPersister);
assertTrue(barsPersister instanceof Wrapper);
}


Expand All @@ -122,7 +124,9 @@ public void testGetClassMetadata() throws Exception {
@Test
public void testGetCollectionMetadata() throws Exception {
assertNull(sessionFactoryWrapper.getCollectionMetadata("bars"));
assertNotNull(sessionFactoryWrapper.getCollectionMetadata(Foo.class.getName() + ".bars"));
CollectionPersister barsPersister = sessionFactoryWrapper.getCollectionMetadata(Foo.class.getName() + ".bars");
assertNotNull(barsPersister);
assertTrue(barsPersister instanceof Wrapper);
}

}

0 comments on commit 6770197

Please sign in to comment.