Intermittent test failure (Sybase)

This commit is contained in:
Steve Ebersole 2022-03-15 12:35:45 -05:00
parent f82d381fe3
commit 8c052054a8
2 changed files with 22 additions and 14 deletions

View File

@ -30,24 +30,32 @@ public class DynamicMapTest {
@Test @Test
public void bootstrappingTest(SessionFactoryScope scope) { public void bootstrappingTest(SessionFactoryScope scope) {
scope.inTransaction( session -> { scope.inTransaction( session -> {
Map item1 = new HashMap(); final Map<String,Object> item1 = new HashMap<>();
item1.put( "name", "cup" ); item1.put( "name", "cup" );
item1.put( "description", "abc" ); item1.put( "description", "abc" );
Map entity1 = new HashMap();
final Map<String,Object> entity1 = new HashMap<>();
entity1.put( "name", "first_entity" ); entity1.put( "name", "first_entity" );
item1.put( "entity", entity1 ); item1.put( "entity", entity1 );
session.save( "Entity1", entity1 );
session.save( "Item1", item1 ); session.persist( "Entity1", entity1 );
session.persist( "Item1", item1 );
} ); } );
scope.inTransaction( session -> { scope.inTransaction( session -> {
List result = session.createQuery( "from Item1" ).list(); //noinspection rawtypes
final List<Map> result = session.createSelectionQuery( "from Item1", Map.class ).list();
assertThat( result.size(), is( 1 ) ); assertThat( result.size(), is( 1 ) );
Map item1 = (Map) result.get( 0 );
//noinspection unchecked
final Map<String,Object> item1 = (Map<String, Object>) result.get( 0 );
assertThat( item1.get( "name" ), is( "cup" ) ); assertThat( item1.get( "name" ), is( "cup" ) );
Object entity1 = item1.get( "entity" );
final Object entity1 = item1.get( "entity" );
assertThat( entity1, notNullValue() ); assertThat( entity1, notNullValue() );
assertThat( ( (Map) entity1 ).get( "name" ), is( "first_entity" ) );
//noinspection unchecked
assertThat( ( (Map<String,Object>) entity1 ).get( "name" ), is( "first_entity" ) );
} ); } );
} }
} }

View File

@ -12,8 +12,8 @@
<class entity-name="ItemBase" abstract="true"> <class entity-name="ItemBase" abstract="true">
<tuplizer entity-mode="dynamic-map" class="org.hibernate.tuple.entity.DynamicMapEntityTuplizer"/> <tuplizer entity-mode="dynamic-map" class="org.hibernate.tuple.entity.DynamicMapEntityTuplizer"/>
<id name="id" type="uuid-binary" column="id" length="16"> <id name="id" type="integer" column="id" length="16">
<generator class="uuid2" /> <generator class="increment" />
</id> </id>
<property name="name" type="string" column="name" length="50" not-null="true" /> <property name="name" type="string" column="name" length="50" not-null="true" />
<property name="description" type="string" column="description" length="200" /> <property name="description" type="string" column="description" length="200" />
@ -33,8 +33,8 @@
<class entity-name="Entity1" table="entity_1"> <class entity-name="Entity1" table="entity_1">
<tuplizer entity-mode="dynamic-map" class="org.hibernate.tuple.entity.DynamicMapEntityTuplizer"/> <tuplizer entity-mode="dynamic-map" class="org.hibernate.tuple.entity.DynamicMapEntityTuplizer"/>
<id name="id" type="uuid-binary" column="id" length="16"> <id name="id" type="integer" column="id" length="16">
<generator class="uuid2" /> <generator class="increment" />
</id> </id>
<property name="name" type="string" column="name" length="50" not-null="true" /> <property name="name" type="string" column="name" length="50" not-null="true" />
<set name="items" fetch="select" lazy="true" inverse="true"> <set name="items" fetch="select" lazy="true" inverse="true">
@ -45,8 +45,8 @@
<class entity-name="Entity2" table="entity_2"> <class entity-name="Entity2" table="entity_2">
<tuplizer entity-mode="dynamic-map" class="org.hibernate.tuple.entity.DynamicMapEntityTuplizer"/> <tuplizer entity-mode="dynamic-map" class="org.hibernate.tuple.entity.DynamicMapEntityTuplizer"/>
<id name="id" type="uuid-binary" column="id" length="16"> <id name="id" type="integer" column="id" length="16">
<generator class="uuid2" /> <generator class="increment" />
</id> </id>
<property name="name" type="nstring" column="name" length="50" not-null="true" /> <property name="name" type="nstring" column="name" length="50" not-null="true" />
<set name="items" fetch="select" lazy="true" inverse="true"> <set name="items" fetch="select" lazy="true" inverse="true">