JAVA-30208: Changes made for adding spring-hibernate-5 (#15659)
This commit is contained in:
parent
faaf189afb
commit
4bde015e08
|
@ -102,7 +102,7 @@
|
||||||
<module>spring-data-solr</module>
|
<module>spring-data-solr</module>
|
||||||
<module>spring-data-shardingsphere</module>
|
<module>spring-data-shardingsphere</module>
|
||||||
<module>spring-hibernate-3</module>
|
<module>spring-hibernate-3</module>
|
||||||
<!-- <module>spring-hibernate-5</module> FAILED --> <!-- long running -->
|
<module>spring-hibernate-5</module>
|
||||||
<module>spring-hibernate-6</module>
|
<module>spring-hibernate-6</module>
|
||||||
<module>spring-jpa</module>
|
<module>spring-jpa</module>
|
||||||
<module>spring-jpa-2</module>
|
<module>spring-jpa-2</module>
|
||||||
|
|
|
@ -125,6 +125,20 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<argLine>
|
||||||
|
--add-opens java.base/java.lang=ALL-UNNAMED
|
||||||
|
</argLine>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<org.springframework.version>5.0.2.RELEASE</org.springframework.version>
|
<org.springframework.version>5.0.2.RELEASE</org.springframework.version>
|
||||||
|
@ -132,7 +146,7 @@
|
||||||
<org.springframework.security.version>4.2.1.RELEASE</org.springframework.security.version>
|
<org.springframework.security.version>4.2.1.RELEASE</org.springframework.security.version>
|
||||||
<!-- persistence -->
|
<!-- persistence -->
|
||||||
<hibernate.version>5.6.15.Final</hibernate.version>
|
<hibernate.version>5.6.15.Final</hibernate.version>
|
||||||
<hibernatesearch.version>5.8.2.Final</hibernatesearch.version>
|
<hibernatesearch.version>5.11.12.Final</hibernatesearch.version>
|
||||||
<mysql-connector-java.version>8.2.0</mysql-connector-java.version>
|
<mysql-connector-java.version>8.2.0</mysql-connector-java.version>
|
||||||
<tomcat-dbcp.version>9.0.0.M26</tomcat-dbcp.version>
|
<tomcat-dbcp.version>9.0.0.M26</tomcat-dbcp.version>
|
||||||
<jta.version>1.1</jta.version>
|
<jta.version>1.1</jta.version>
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ehcache xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
|
||||||
|
monitoring="autodetect" dynamicConfig="true">
|
||||||
|
|
||||||
|
<diskStore path="java.io.tmpdir/ehcache" />
|
||||||
|
|
||||||
|
<defaultCache maxEntriesLocalHeap="10000" eternal="false"
|
||||||
|
timeToIdleSeconds="120" timeToLiveSeconds="120" diskSpoolBufferSizeMB="30"
|
||||||
|
maxEntriesLocalDisk="10000000" diskExpiryThreadIntervalSeconds="120"
|
||||||
|
memoryStoreEvictionPolicy="LRU" statistics="true">
|
||||||
|
<persistence strategy="localTempSwap" />
|
||||||
|
</defaultCache>
|
||||||
|
|
||||||
|
<cache name="org.hibernate.cache.internal.StandardQueryCache"
|
||||||
|
maxEntriesLocalHeap="5" eternal="false" timeToLiveSeconds="120">
|
||||||
|
<persistence strategy="localTempSwap" />
|
||||||
|
</cache>
|
||||||
|
|
||||||
|
</ehcache>
|
|
@ -7,13 +7,13 @@ import javax.persistence.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "FOO")
|
@Table(name = "FOO")
|
||||||
@Where(clause = "DELETED = 0")
|
@Where(clause = "DELETED = 0")
|
||||||
public class Foo {
|
public class Fooo {
|
||||||
|
|
||||||
public Foo() {
|
public Fooo() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Foo(final String name) {
|
public Fooo(final String name) {
|
||||||
super();
|
super();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.baeldung.persistence.deletion.config.PersistenceJPAConfigDeletion;
|
import com.baeldung.persistence.deletion.config.PersistenceJPAConfigDeletion;
|
||||||
import com.baeldung.persistence.deletion.model.Bar;
|
import com.baeldung.persistence.deletion.model.Bar;
|
||||||
import com.baeldung.persistence.deletion.model.Baz;
|
import com.baeldung.persistence.deletion.model.Baz;
|
||||||
import com.baeldung.persistence.deletion.model.Foo;
|
import com.baeldung.persistence.deletion.model.Fooo;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
@ -41,29 +41,29 @@ public class DeletionIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public final void givenEntityIsRemoved_thenItIsNotInDB() {
|
public final void givenEntityIsRemoved_thenItIsNotInDB() {
|
||||||
Foo foo = new Foo("foo");
|
Fooo fooo = new Fooo("foo");
|
||||||
entityManager.persist(foo);
|
entityManager.persist(fooo);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
foo = entityManager.find(Foo.class, foo.getId());
|
fooo = entityManager.find(Fooo.class, fooo.getId());
|
||||||
assertThat(foo, notNullValue());
|
assertThat(fooo, notNullValue());
|
||||||
|
|
||||||
entityManager.remove(foo);
|
entityManager.remove(fooo);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
|
assertThat(entityManager.find(Fooo.class, fooo.getId()), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public final void givenEntityIsRemovedAndReferencedByAnotherEntity_thenItIsNotRemoved() {
|
public final void givenEntityIsRemovedAndReferencedByAnotherEntity_thenItIsNotRemoved() {
|
||||||
Bar bar = new Bar("bar");
|
Bar bar = new Bar("bar");
|
||||||
Foo foo = new Foo("foo");
|
Fooo fooo = new Fooo("foo");
|
||||||
foo.setBar(bar);
|
fooo.setBar(bar);
|
||||||
entityManager.persist(foo);
|
entityManager.persist(fooo);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
foo = entityManager.find(Foo.class, foo.getId());
|
fooo = entityManager.find(Fooo.class, fooo.getId());
|
||||||
bar = entityManager.find(Bar.class, bar.getId());
|
bar = entityManager.find(Bar.class, bar.getId());
|
||||||
entityManager.remove(bar);
|
entityManager.remove(bar);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
@ -71,8 +71,8 @@ public class DeletionIntegrationTest {
|
||||||
bar = entityManager.find(Bar.class, bar.getId());
|
bar = entityManager.find(Bar.class, bar.getId());
|
||||||
assertThat(bar, notNullValue());
|
assertThat(bar, notNullValue());
|
||||||
|
|
||||||
foo = entityManager.find(Foo.class, foo.getId());
|
fooo = entityManager.find(Fooo.class, fooo.getId());
|
||||||
foo.setBar(null);
|
fooo.setBar(null);
|
||||||
entityManager.remove(bar);
|
entityManager.remove(bar);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
|
@ -83,16 +83,16 @@ public class DeletionIntegrationTest {
|
||||||
@Transactional
|
@Transactional
|
||||||
public final void givenEntityIsRemoved_thenRemovalIsCascaded() {
|
public final void givenEntityIsRemoved_thenRemovalIsCascaded() {
|
||||||
Bar bar = new Bar("bar");
|
Bar bar = new Bar("bar");
|
||||||
Foo foo = new Foo("foo");
|
Fooo fooo = new Fooo("foo");
|
||||||
foo.setBar(bar);
|
fooo.setBar(bar);
|
||||||
entityManager.persist(foo);
|
entityManager.persist(fooo);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
foo = entityManager.find(Foo.class, foo.getId());
|
fooo = entityManager.find(Fooo.class, fooo.getId());
|
||||||
entityManager.remove(foo);
|
entityManager.remove(fooo);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
|
assertThat(entityManager.find(Fooo.class, fooo.getId()), nullValue());
|
||||||
assertThat(entityManager.find(Bar.class, bar.getId()), nullValue());
|
assertThat(entityManager.find(Bar.class, bar.getId()), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,39 +116,39 @@ public class DeletionIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public final void givenEntityIsDeletedWithJpaBulkDeleteStatement_thenItIsNotInDB() {
|
public final void givenEntityIsDeletedWithJpaBulkDeleteStatement_thenItIsNotInDB() {
|
||||||
Foo foo = new Foo("foo");
|
Fooo fooo = new Fooo("foo");
|
||||||
entityManager.persist(foo);
|
entityManager.persist(fooo);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
entityManager.createQuery("delete from Foo where id = :id").setParameter("id", foo.getId()).executeUpdate();
|
entityManager.createQuery("delete from Foo where id = :id").setParameter("id", fooo.getId()).executeUpdate();
|
||||||
|
|
||||||
assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
|
assertThat(entityManager.find(Fooo.class, fooo.getId()), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public final void givenEntityIsDeletedWithNativeQuery_thenItIsNotInDB() {
|
public final void givenEntityIsDeletedWithNativeQuery_thenItIsNotInDB() {
|
||||||
Foo foo = new Foo("foo");
|
Fooo fooo = new Fooo("foo");
|
||||||
entityManager.persist(foo);
|
entityManager.persist(fooo);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
entityManager.createNativeQuery("delete from FOO where ID = :id").setParameter("id", foo.getId()).executeUpdate();
|
entityManager.createNativeQuery("delete from FOO where ID = :id").setParameter("id", fooo.getId()).executeUpdate();
|
||||||
|
|
||||||
assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
|
assertThat(entityManager.find(Fooo.class, fooo.getId()), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public final void givenEntityIsSoftDeleted_thenItIsNotReturnedFromQueries() {
|
public final void givenEntityIsSoftDeleted_thenItIsNotReturnedFromQueries() {
|
||||||
Foo foo = new Foo("foo");
|
Fooo fooo = new Fooo("foo");
|
||||||
entityManager.persist(foo);
|
entityManager.persist(fooo);
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
foo = entityManager.find(Foo.class, foo.getId());
|
fooo = entityManager.find(Fooo.class, fooo.getId());
|
||||||
foo.setDeleted();
|
fooo.setDeleted();
|
||||||
flushAndClear();
|
flushAndClear();
|
||||||
|
|
||||||
assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
|
assertThat(entityManager.find(Fooo.class, fooo.getId()), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void flushAndClear() {
|
private void flushAndClear() {
|
||||||
|
|
Loading…
Reference in New Issue