Skip to content

Commit

Permalink
Add test case to replicate #245
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmihalcea committed Jun 17, 2024
1 parent 069dea7 commit e5a6cf1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hypersistence-optimizer-spring-boot3-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,36 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-jcache</artifactId>
<version>${hibernate.version}</version>
</dependency>

<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>${ehcache.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<properties>
<jdk.version>17</jdk.version>

<spring-boot.version>3.2.0</spring-boot.version>
<hikari.version>3.4.5</hikari.version>
<ehcache.version>3.10.8</ehcache.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.NaturalIdCache;

/**
* @author Vlad Mihalcea
*/
@Entity
@Table(name = "tag")
@NaturalIdCache
public class Tag {

@Id
@GeneratedValue
private Long id;

@NaturalId
private String name;

public Long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.hypersistence.optimizer.hibernate.event.mapping.association.OneToOneParentSideEvent;
import io.hypersistence.optimizer.hibernate.event.mapping.association.OneToOneWithoutMapsIdEvent;
import io.hypersistence.optimizer.hibernate.event.mapping.association.fetching.EagerFetchingEvent;
import io.hypersistence.optimizer.hibernate.event.mapping.cache.NaturalIdCacheEvent;
import io.hypersistence.optimizer.hibernate.event.query.PaginationWithoutOrderByEvent;
import io.hypersistence.optimizer.hibernate.event.session.SessionTimeoutEvent;
import jakarta.persistence.EntityManager;
Expand Down Expand Up @@ -105,6 +106,7 @@ public void test() throws ExecutionException, InterruptedException {
assertEventTriggered(1, SchemaGenerationEvent.class);
assertEventTriggered(1, QueryPaginationCollectionFetchingEvent.class);
assertEventTriggered(1, QueryInClauseParameterPaddingEvent.class);
assertEventTriggered(0, NaturalIdCacheEvent.class);

Post newPost = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ spring.datasource.username=sa
spring.datasource.password=

spring.jpa.properties.hypersistence.session.timeout_millis=25
spring.jpa.properties.hibernate.cache.region.factory_class=jcache
spring.jpa.open-in-view=false

0 comments on commit e5a6cf1

Please sign in to comment.