HHH-17380 Add test for issue
This commit is contained in:
parent
23a809fc3c
commit
7ac11026d4
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
~ 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>.
|
||||
-->
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping package="org.hibernate.test.version">
|
||||
|
||||
<class name="NewEntityWithNullVersionTest$UserAttributes" table="user_attributes">
|
||||
<id name="id" type="java.lang.Long" unsaved-value="0"/>
|
||||
<version name="version" type="java.lang.Long" access="field"/>
|
||||
<property name="name"/>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,68 @@
|
|||
package org.hibernate.test.version;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-17380")
|
||||
public class NewEntityWithNullVersionTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected String[] getMappings() {
|
||||
return new String[] { "NewEntityWithNullVersion.hbm.xml" };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBaseForMappings() {
|
||||
return super.getBaseForMappings() + "version/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergeDetachedEntityWithIdentityId() {
|
||||
UserAttributes item = new UserAttributes();
|
||||
item.id = 123L;
|
||||
item.name = "Abc";
|
||||
inTransaction(
|
||||
session -> {
|
||||
session.saveOrUpdate( item );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static class UserAttributes implements Serializable {
|
||||
|
||||
private Long id = 0L;
|
||||
|
||||
private Long version;
|
||||
|
||||
private String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue