HHH-13179 Fixed code formatting issue

This commit is contained in:
Lars Karlström 2020-02-19 14:45:24 +01:00 committed by Steve Ebersole
parent 4413433ace
commit 02c3cc9e2e
2 changed files with 34 additions and 29 deletions

View File

@ -523,7 +523,7 @@ public class ModelBinder {
PersistentClass superEntityDescriptor) { PersistentClass superEntityDescriptor) {
for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) {
final SingleTableSubclass subEntityDescriptor = new SingleTableSubclass( superEntityDescriptor, metadataBuildingContext ); final SingleTableSubclass subEntityDescriptor = new SingleTableSubclass( superEntityDescriptor, metadataBuildingContext );
subEntityDescriptor.setCached(superEntityDescriptor.isCached()); subEntityDescriptor.setCached( superEntityDescriptor.isCached() );
bindDiscriminatorSubclassEntity( (SubclassEntitySourceImpl) subType, subEntityDescriptor ); bindDiscriminatorSubclassEntity( (SubclassEntitySourceImpl) subType, subEntityDescriptor );
superEntityDescriptor.addSubclass( subEntityDescriptor ); superEntityDescriptor.addSubclass( subEntityDescriptor );
entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor ); entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor );
@ -582,7 +582,7 @@ public class ModelBinder {
PersistentClass superEntityDescriptor) { PersistentClass superEntityDescriptor) {
for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) {
final JoinedSubclass subEntityDescriptor = new JoinedSubclass( superEntityDescriptor, metadataBuildingContext ); final JoinedSubclass subEntityDescriptor = new JoinedSubclass( superEntityDescriptor, metadataBuildingContext );
subEntityDescriptor.setCached(superEntityDescriptor.isCached()); subEntityDescriptor.setCached( superEntityDescriptor.isCached() );
bindJoinedSubclassEntity( (JoinedSubclassEntitySourceImpl) subType, subEntityDescriptor ); bindJoinedSubclassEntity( (JoinedSubclassEntitySourceImpl) subType, subEntityDescriptor );
superEntityDescriptor.addSubclass( subEntityDescriptor ); superEntityDescriptor.addSubclass( subEntityDescriptor );
entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor ); entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor );
@ -659,7 +659,7 @@ public class ModelBinder {
PersistentClass superEntityDescriptor) { PersistentClass superEntityDescriptor) {
for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) {
final UnionSubclass subEntityDescriptor = new UnionSubclass( superEntityDescriptor, metadataBuildingContext ); final UnionSubclass subEntityDescriptor = new UnionSubclass( superEntityDescriptor, metadataBuildingContext );
subEntityDescriptor.setCached(superEntityDescriptor.isCached()); subEntityDescriptor.setCached( superEntityDescriptor.isCached() );
bindUnionSubclassEntity( (SubclassEntitySourceImpl) subType, subEntityDescriptor ); bindUnionSubclassEntity( (SubclassEntitySourceImpl) subType, subEntityDescriptor );
superEntityDescriptor.addSubclass( subEntityDescriptor ); superEntityDescriptor.addSubclass( subEntityDescriptor );
entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor ); entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor );

View File

@ -20,6 +20,7 @@ import org.hibernate.Transaction;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.stat.CacheRegionStatistics; import org.hibernate.stat.CacheRegionStatistics;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Assert; import org.junit.Assert;
@ -28,7 +29,7 @@ import org.junit.Test;
/** /**
* Check that second level caching works for hbm mapped joined subclass inheritance structures * Check that second level caching works for hbm mapped joined subclass inheritance structures
*/ */
@TestForIssue( jiraKey = "HHH-13179") @TestForIssue(jiraKey = "HHH-13179")
public class HHH13179Test extends BaseCoreFunctionalTestCase { public class HHH13179Test extends BaseCoreFunctionalTestCase {
// Add your entities here. // Add your entities here.
@ -56,6 +57,7 @@ public class HHH13179Test extends BaseCoreFunctionalTestCase {
"org/hibernate/test/cache/hhh13179/DiscriminatorSubclassPerson.hbm.xml" "org/hibernate/test/cache/hhh13179/DiscriminatorSubclassPerson.hbm.xml"
}; };
} }
// If those mappings reside somewhere other than resources/org/hibernate/test, change this. // If those mappings reside somewhere other than resources/org/hibernate/test, change this.
@Override @Override
protected String getBaseForMappings() { protected String getBaseForMappings() {
@ -81,12 +83,13 @@ public class HHH13179Test extends BaseCoreFunctionalTestCase {
String regionName = "org.hibernate.test.cache.hhh13179.JoinedSubclassPerson"; String regionName = "org.hibernate.test.cache.hhh13179.JoinedSubclassPerson";
// sanity check // sanity check
CacheRegionStatistics cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(regionName); CacheRegionStatistics cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(
Assert.assertEquals("Cache put should be 0", 0, cacheRegionStatistics.getPutCount()); regionName );
Assert.assertEquals( "Cache put should be 0", 0, cacheRegionStatistics.getPutCount() );
JoinedSubclassPerson person1 = new JoinedSubclassUIPerson(); JoinedSubclassPerson person1 = new JoinedSubclassUIPerson();
person1.setOid(1L); person1.setOid( 1L );
s.save(person1); s.save( person1 );
tx.commit(); tx.commit();
@ -95,11 +98,11 @@ public class HHH13179Test extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
JoinedSubclassPerson person2 = s.get(JoinedSubclassPerson.class, 1L); JoinedSubclassPerson person2 = s.get( JoinedSubclassPerson.class, 1L );
cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(regionName); cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics( regionName );
Assert.assertEquals("Cache hit should be 1", 1, cacheRegionStatistics.getHitCount()); Assert.assertEquals( "Cache hit should be 1", 1, cacheRegionStatistics.getHitCount() );
Assert.assertEquals("Cache put should be 1", 1, cacheRegionStatistics.getPutCount()); Assert.assertEquals( "Cache put should be 1", 1, cacheRegionStatistics.getPutCount() );
tx.commit(); tx.commit();
s.close(); s.close();
@ -114,12 +117,13 @@ public class HHH13179Test extends BaseCoreFunctionalTestCase {
String regionName = "org.hibernate.test.cache.hhh13179.UnionSubclassPerson"; String regionName = "org.hibernate.test.cache.hhh13179.UnionSubclassPerson";
// sanity check // sanity check
CacheRegionStatistics cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(regionName); CacheRegionStatistics cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(
Assert.assertEquals("Cache put should be 0", 0, cacheRegionStatistics.getPutCount()); regionName );
Assert.assertEquals( "Cache put should be 0", 0, cacheRegionStatistics.getPutCount() );
UnionSubclassPerson person1 = new UnionSubclassUIPerson(); UnionSubclassPerson person1 = new UnionSubclassUIPerson();
person1.setOid(1L); person1.setOid( 1L );
s.save(person1); s.save( person1 );
tx.commit(); tx.commit();
@ -128,11 +132,11 @@ public class HHH13179Test extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
UnionSubclassPerson person2 = s.get(UnionSubclassPerson.class, 1L); UnionSubclassPerson person2 = s.get( UnionSubclassPerson.class, 1L );
cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(regionName); cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics( regionName );
Assert.assertEquals("Cache hit should be 1", 1, cacheRegionStatistics.getHitCount()); Assert.assertEquals( "Cache hit should be 1", 1, cacheRegionStatistics.getHitCount() );
Assert.assertEquals("Cache put should be 1", 1, cacheRegionStatistics.getPutCount()); Assert.assertEquals( "Cache put should be 1", 1, cacheRegionStatistics.getPutCount() );
tx.commit(); tx.commit();
s.close(); s.close();
@ -147,12 +151,13 @@ public class HHH13179Test extends BaseCoreFunctionalTestCase {
String regionName = "org.hibernate.test.cache.hhh13179.DiscriminatorSubclassPerson"; String regionName = "org.hibernate.test.cache.hhh13179.DiscriminatorSubclassPerson";
// sanity check // sanity check
CacheRegionStatistics cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(regionName); CacheRegionStatistics cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(
Assert.assertEquals("Cache put should be 0", 0, cacheRegionStatistics.getPutCount()); regionName );
Assert.assertEquals( "Cache put should be 0", 0, cacheRegionStatistics.getPutCount() );
DiscriminatorSubclassPerson person1 = new DiscriminatorSubclassUIPerson(); DiscriminatorSubclassPerson person1 = new DiscriminatorSubclassUIPerson();
person1.setOid(1L); person1.setOid( 1L );
s.save(person1); s.save( person1 );
tx.commit(); tx.commit();
@ -161,11 +166,11 @@ public class HHH13179Test extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
DiscriminatorSubclassPerson person2 = s.get(DiscriminatorSubclassPerson.class, 1L); DiscriminatorSubclassPerson person2 = s.get( DiscriminatorSubclassPerson.class, 1L );
cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics(regionName); cacheRegionStatistics = s.getSessionFactory().getStatistics().getCacheRegionStatistics( regionName );
Assert.assertEquals("Cache hit should be 1", 1, cacheRegionStatistics.getHitCount()); Assert.assertEquals( "Cache hit should be 1", 1, cacheRegionStatistics.getHitCount() );
Assert.assertEquals("Cache put should be 1", 1, cacheRegionStatistics.getPutCount()); Assert.assertEquals( "Cache put should be 1", 1, cacheRegionStatistics.getPutCount() );
tx.commit(); tx.commit();
s.close(); s.close();