From 3aac27d369f86a9639e38eec63683b3b67dad1cb Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Tue, 22 May 2018 17:44:19 -0400 Subject: [PATCH] HHH-12587 - Added test case. --- .../test/cache/CacheAnnotationTests.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/cache/CacheAnnotationTests.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/cache/CacheAnnotationTests.java b/hibernate-core/src/test/java/org/hibernate/test/cache/CacheAnnotationTests.java new file mode 100644 index 0000000000..eb4e0db2ce --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/cache/CacheAnnotationTests.java @@ -0,0 +1,66 @@ +/* + * 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 . + */ +package org.hibernate.test.cache; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.cfg.Configuration; +import org.junit.Test; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; + +import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; + +/** + * @author Chris Cranford + */ +@TestForIssue(jiraKey = "HHH-12587") +public class CacheAnnotationTests extends BaseCoreFunctionalTestCase { + + @Override + protected void configure(Configuration configuration) { + super.configure( configuration ); + configuration.setProperty( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); + } + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { NoCacheConcurrencyStrategyEntity.class }; + } + + @Test + public void testCacheConcurrencyStrategyNone() { + doInHibernate( this::sessionFactory, session -> { + NoCacheConcurrencyStrategyEntity entity = new NoCacheConcurrencyStrategyEntity(); + session.save( entity ); + session.flush(); + session.clear(); + } ); + } + + @Entity(name = "NoCacheConcurrencyStrategyEntity") + @Cache(usage = CacheConcurrencyStrategy.NONE) + public static class NoCacheConcurrencyStrategyEntity { + @Id + @GeneratedValue + private Integer id; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + } +}