HHH-8382 - Added test case.
This commit is contained in:
parent
33159c13a6
commit
a0b94f057a
|
@ -0,0 +1,27 @@
|
|||
<?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 2.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.lob">
|
||||
|
||||
<class name="LobAsLastValueEntity">
|
||||
<id name="id" type="integer">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<!-- property that maps to clob/blob/varbinary/nclob via sql types -->
|
||||
<property name="details" type="string" length="4000">
|
||||
<column name="details" sql-type="clob"/>
|
||||
</property>
|
||||
<!-- property that specifies hibernate type that internally maps to clob/blob/nclob sql types -->
|
||||
<property name="title" length="4000" type="materialized_clob" />
|
||||
<property name="name" type="string" length="120"/>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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.test.lob;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Chris Cranford
|
||||
*/
|
||||
public class LobAsLastValueEntity implements Serializable {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String details;
|
||||
private String title;
|
||||
|
||||
public LobAsLastValueEntity() {
|
||||
|
||||
}
|
||||
|
||||
public LobAsLastValueEntity(String name, String details, String title) {
|
||||
this.name = name;
|
||||
this.details = details;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(String details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
LobAsLastValueEntity that = (LobAsLastValueEntity) o;
|
||||
return Objects.equals( id, that.id ) &&
|
||||
Objects.equals( details, that.details ) &&
|
||||
Objects.equals( title, that.title );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( id, details, title );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.test.lob;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
|
||||
/**
|
||||
* @author Chris Cranford
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsForceLobAsLastValue.class)
|
||||
@TestForIssue(jiraKey = "HHH-8382")
|
||||
public class LobAsLastValueTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
protected String[] getMappings() {
|
||||
return new String[] { "lob/LobAsLastValue.hbm.xml" };
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertLobAsLastValue() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
byte[] details = new byte[4000];
|
||||
byte[] title = new byte[2000];
|
||||
|
||||
Random random = new Random();
|
||||
random.nextBytes( details );
|
||||
random.nextBytes( title );
|
||||
|
||||
// This insert will fail on Oracle without the fix to ModelBinder flagging SimpleValue and Property as Lob
|
||||
// because the fields will not be placed at the end of the insert, resulting in an Oracle failure.
|
||||
final LobAsLastValueEntity entity = new LobAsLastValueEntity( "Test", new String( details ), new String( title ) );
|
||||
session.save( entity );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
|
@ -235,4 +235,10 @@ abstract public class DialectChecks {
|
|||
return dialect.dropConstraints();
|
||||
}
|
||||
}
|
||||
|
||||
public static class SupportsForceLobAsLastValue implements DialectCheck {
|
||||
public boolean isMatch(Dialect dialect) {
|
||||
return dialect.forceLobAsLastValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue