Skip to content

Commit

Permalink
HBX-2739: Create Interface for ClassMetadataWrapper
Browse files Browse the repository at this point in the history
  - Add new test case 'org.hibernate.tool.orm.jbt.api.ClassMetadataWrapperTest#testGetTuplizerPropertyValue()'
  - Add new default interface method 'org.hibernate.tool.orm.jbt.api.ClassMetadataWrapper#getTuplizerPropertyValue(Object,int)'

Signed-off-by: Koen Aers <koen.aers@gmail.com>
  • Loading branch information
koentsje committed Feb 29, 2024
1 parent 37f4972 commit d7c20ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public interface ClassMetadataWrapper extends Wrapper {
default Object getIdentifier(Object object, Session session) { return ((EntityPersister)getWrappedObject()).getIdentifier(object, (SharedSessionContractImplementor)session); }
default boolean isInstanceOfAbstractEntityPersister() { return (EntityPersister)getWrappedObject() instanceof AbstractEntityPersister; }
default Integer getPropertyIndexOrNull(String id) { return ((EntityPersister)getWrappedObject()).getEntityMetamodel().getPropertyIndexOrNull(id); }
default Object getTuplizerPropertyValue(Object entity, int i) { return ((EntityPersister)getWrappedObject()).getValue(entity, i); }

}
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,12 @@ public void testGetPropertyIndexOrNull() {
assertNull(classMetadataWrapper.getPropertyIndexOrNull("foo"));
}

@Test
public void testGetTuplizerPropertyValue() {
Foo foo = new Foo();
Set<String> bars = Set.of("foo", "bar");
foo.bars = bars;
assertSame(bars, classMetadataWrapper.getTuplizerPropertyValue(foo, 0));
}

}

0 comments on commit d7c20ce

Please sign in to comment.