HHH-12700 - Missing property in sample code in documentation of bulk-id strategies
This commit is contained in:
parent
f0a31fbc3d
commit
d4861fed9f
|
@ -317,7 +317,7 @@ The `Person` entity is the base class of this entity inheritance model, and is m
|
|||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{bulkid-sourcedir}/AbstractBulkIdTest.java[tags=batch-bulk-hql-temp-table-base-class-example]
|
||||
include::{bulkid-sourcedir}/AbstractBulkCompositeIdTest.java[tags=batch-bulk-hql-temp-table-base-class-example]
|
||||
----
|
||||
====
|
||||
|
||||
|
@ -328,7 +328,7 @@ Both the `Doctor` and `Engineer` entity classes extend the `Person` base class:
|
|||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{bulkid-sourcedir}/AbstractBulkIdTest.java[tags=batch-bulk-hql-temp-table-sub-classes-example]
|
||||
include::{bulkid-sourcedir}/AbstractBulkCompositeIdTest.java[tags=batch-bulk-hql-temp-table-sub-classes-example]
|
||||
----
|
||||
====
|
||||
|
||||
|
@ -342,7 +342,7 @@ Now, when you try to execute a bulk entity delete query:
|
|||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{bulkid-sourcedir}/AbstractBulkIdTest.java[tags=batch-bulk-hql-temp-table-delete-query-example]
|
||||
include::{bulkid-sourcedir}/AbstractBulkCompositeIdTest.java[tags=batch-bulk-hql-temp-table-delete-query-example]
|
||||
----
|
||||
|
||||
[source, SQL, indent=0]
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.hibernate.test.bulkid;
|
|||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
|
@ -12,8 +11,6 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -77,7 +74,7 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
}
|
||||
|
||||
protected int entityCount() {
|
||||
return 100;
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -95,9 +92,12 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
@Test
|
||||
public void testDeleteFromPerson() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
int updateCount = session.createQuery( "delete from Person where employed = :employed" )
|
||||
.setParameter( "employed", false )
|
||||
.executeUpdate();
|
||||
//tag::batch-bulk-hql-temp-table-delete-query-example[]
|
||||
int updateCount = session.createQuery(
|
||||
"delete from Person where employed = :employed" )
|
||||
.setParameter( "employed", false )
|
||||
.executeUpdate();
|
||||
//end::batch-bulk-hql-temp-table-delete-query-example[]
|
||||
assertEquals( entityCount(), updateCount );
|
||||
});
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
});
|
||||
}
|
||||
|
||||
//tag::batch-bulk-hql-temp-table-base-class-example[]
|
||||
@Entity(name = "Person")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public static class Person implements Serializable {
|
||||
|
@ -176,7 +177,9 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
return Objects.hash( getId(), getCompanyName() );
|
||||
}
|
||||
}
|
||||
//end::batch-bulk-hql-temp-table-base-class-example[]
|
||||
|
||||
//tag::batch-bulk-hql-temp-table-sub-classes-example[]
|
||||
@Entity(name = "Doctor")
|
||||
public static class Doctor extends Person {
|
||||
}
|
||||
|
@ -194,4 +197,5 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
this.fellow = fellow;
|
||||
}
|
||||
}
|
||||
//end::batch-bulk-hql-temp-table-sub-classes-example[]
|
||||
}
|
|
@ -10,8 +10,6 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -89,12 +87,10 @@ public abstract class AbstractBulkIdTest extends BaseCoreFunctionalTestCase {
|
|||
@Test
|
||||
public void testDeleteFromPerson() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
//tag::batch-bulk-hql-temp-table-delete-query-example[]
|
||||
int updateCount = session.createQuery(
|
||||
"delete from Person where employed = :employed" )
|
||||
.setParameter( "employed", false )
|
||||
.executeUpdate();
|
||||
//end::batch-bulk-hql-temp-table-delete-query-example[]
|
||||
assertEquals( entityCount(), updateCount );
|
||||
});
|
||||
}
|
||||
|
@ -109,7 +105,6 @@ public abstract class AbstractBulkIdTest extends BaseCoreFunctionalTestCase {
|
|||
});
|
||||
}
|
||||
|
||||
//tag::batch-bulk-hql-temp-table-base-class-example[]
|
||||
@Entity(name = "Person")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public static class Person {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package org.hibernate.test.bulkid;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
||||
import org.hibernate.hql.spi.id.inline.InlineIdsInClauseBulkIdStrategy;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialect(PostgreSQL82Dialect.class)
|
||||
public class GlobalTemporaryTableBulkCompositeIdTest extends AbstractBulkCompositeIdTest {
|
||||
|
||||
@Override
|
||||
protected Class<? extends MultiTableBulkIdStrategy> getMultiTableBulkIdStrategyClass() {
|
||||
return GlobalTemporaryTableBulkIdStrategy.class;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue