DATAJPA-785 - Adapted test cases to build against Hibernate 5 GA.
Added a few flushes and transaction rearrangements for low level integration tests to accommodate changes in flushing behavior in Hibernate 5 GA.
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -54,13 +54,13 @@
|
||||
<profile>
|
||||
<id>hibernate-5</id>
|
||||
<properties>
|
||||
<hibernate>5.0.0.Beta2</hibernate>
|
||||
<hibernate>5.0.0.Final</hibernate>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-5-next</id>
|
||||
<properties>
|
||||
<hibernate>5.0.0-SNAPSHOT</hibernate>
|
||||
<hibernate>5.0.1-SNAPSHOT</hibernate>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
||||
@@ -70,6 +70,7 @@ public class Jsr310JpaConvertersIntegrationTests extends AbstractAttributeConver
|
||||
sample.localDateTime = LocalDateTime.now();
|
||||
|
||||
em.persist(sample);
|
||||
em.flush();
|
||||
em.clear();
|
||||
|
||||
DateTimeSample result = em.find(DateTimeSample.class, sample.id);
|
||||
|
||||
@@ -70,6 +70,7 @@ public class ThreeTenBackPortJpaConvertersIntegrationTests extends AbstractAttri
|
||||
sample.localDateTime = LocalDateTime.now();
|
||||
|
||||
em.persist(sample);
|
||||
em.flush();
|
||||
em.clear();
|
||||
|
||||
DateTimeSample result = em.find(DateTimeSample.class, sample.id);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,9 +57,9 @@ public class JpaMetamodelMappingContextIntegrationTests {
|
||||
|
||||
@Configuration
|
||||
@ImportResource("classpath:infrastructure.xml")
|
||||
@EnableJpaRepositories(basePackageClasses = CategoryRepository.class,//
|
||||
@EnableJpaRepositories(basePackageClasses = CategoryRepository.class, //
|
||||
includeFilters = @Filter(value = { CategoryRepository.class, ProductRepository.class },
|
||||
type = FilterType.ASSIGNABLE_TYPE))
|
||||
type = FilterType.ASSIGNABLE_TYPE) )
|
||||
static class Config {
|
||||
|
||||
}
|
||||
@@ -131,22 +131,29 @@ public class JpaMetamodelMappingContextIntegrationTests {
|
||||
@Test
|
||||
public void lookingUpIdentifierOfProxyDoesNotInitializeProxy() {
|
||||
|
||||
new TransactionTemplate(transactionManager).execute(new TransactionCallback<Void>() {
|
||||
TransactionTemplate template = new TransactionTemplate(transactionManager);
|
||||
final Category category = template.execute(new TransactionCallback<Category>() {
|
||||
|
||||
@Override
|
||||
public Category doInTransaction(TransactionStatus status) {
|
||||
|
||||
Product product = products.save(new Product());
|
||||
return categories.save(new Category(product));
|
||||
}
|
||||
});
|
||||
|
||||
template.execute(new TransactionCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public Void doInTransaction(TransactionStatus status) {
|
||||
|
||||
Product product = products.save(new Product());
|
||||
Category category = categories.save(new Category(product));
|
||||
em.clear();
|
||||
|
||||
Category loaded = categories.findOne(category.getId());
|
||||
Product loadedProduct = loaded.getProduct();
|
||||
|
||||
JpaPersistentEntity<?> entity = context.getPersistentEntity(Product.class);
|
||||
IdentifierAccessor accessor = entity.getIdentifierAccessor(loadedProduct);
|
||||
|
||||
assertThat(accessor.getIdentifier(), is((Object) product.getId()));
|
||||
assertThat(accessor.getIdentifier(), is((Object) category.getProduct().getId()));
|
||||
assertThat(loadedProduct, is(instanceOf(HibernateProxy.class)));
|
||||
assertThat(((HibernateProxy) loadedProduct).getHibernateLazyInitializer().isUninitialized(), is(true));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user