HHH-15201 Add test for issue
This commit is contained in:
parent
a39bf55a65
commit
03410ac24e
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping>
|
||||
<class entity-name="CompId">
|
||||
<composite-id>
|
||||
<key-property name="id1" column="id1" length="32" type="string"/>
|
||||
<key-property name="id2" column="id2" length="32" type="string"/>
|
||||
</composite-id>
|
||||
<property name="name" type="string"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.entitymode.map.compositeId;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
@DomainModel(
|
||||
xmlMappings = "org/hibernate/orm/test/entitymode/map/compositeId/CompId.hbm.xml"
|
||||
)
|
||||
@SessionFactory
|
||||
@TestForIssue(jiraKey = "HHH-15201")
|
||||
public class CompositeIdTest {
|
||||
|
||||
@Test
|
||||
public void testImplicitCompositeIdInDynamicMapMode(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
HashMap<Object, Object> id = new HashMap<>();
|
||||
id.put( "id1", "1" );
|
||||
id.put( "id2", "2" );
|
||||
id.put( "name", "Fab" );
|
||||
|
||||
session.save( "CompId", id );
|
||||
}
|
||||
);
|
||||
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
HashMap<Object, Object> id = new HashMap<>();
|
||||
id.put( "id1", "1" );
|
||||
id.put( "id2", "2" );
|
||||
HashMap<Object, Object> compId = (HashMap<Object, Object>) session.get( "CompId", id );
|
||||
assertNotNull( compId );
|
||||
assertThat( compId.get( "id1" ), is( "1" ) );
|
||||
assertThat( compId.get( "id2" ), is( "2" ) );
|
||||
assertThat( compId.get( "name" ), is( "Fab" ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue