|
|
|
@ -24,7 +24,6 @@ import org.hibernate.SessionFactory; |
|
|
|
import org.hibernate.exception.ConstraintViolationException; |
|
|
|
import org.hibernate.exception.ConstraintViolationException; |
|
|
|
import org.hibernate.exception.GenericJDBCException; |
|
|
|
import org.hibernate.exception.GenericJDBCException; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Ignore; |
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.test.context.ContextConfiguration; |
|
|
|
import org.springframework.test.context.ContextConfiguration; |
|
|
|
@ -34,8 +33,8 @@ import org.springframework.test.context.junit4.orm.domain.Person; |
|
|
|
import org.springframework.test.context.junit4.orm.service.PersonService; |
|
|
|
import org.springframework.test.context.junit4.orm.service.PersonService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Transactional integration tests regarding <i>automatic vs. manual</i> session |
|
|
|
* Transactional integration tests regarding <i>manual</i> session flushing with |
|
|
|
* flushing with Hibernate. |
|
|
|
* Hibernate. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Sam Brannen |
|
|
|
* @author Sam Brannen |
|
|
|
* @since 3.0 |
|
|
|
* @since 3.0 |
|
|
|
@ -78,7 +77,6 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp |
|
|
|
assertNotNull("Juergen's ID should have been set", juergen.getId()); |
|
|
|
assertNotNull("Juergen's ID should have been set", juergen.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Ignore("Disabled until SPR-5699 is resolved") |
|
|
|
|
|
|
|
@Test(expected = ConstraintViolationException.class) |
|
|
|
@Test(expected = ConstraintViolationException.class) |
|
|
|
public void saveJuergenWithNullDriversLicense() { |
|
|
|
public void saveJuergenWithNullDriversLicense() { |
|
|
|
personService.save(new Person(JUERGEN)); |
|
|
|
personService.save(new Person(JUERGEN)); |
|
|
|
@ -91,19 +89,19 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp |
|
|
|
personService.save(sam); |
|
|
|
personService.save(sam); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected = GenericJDBCException.class) |
|
|
|
@Test |
|
|
|
// @IfProfileValue(name = "spring-compatibility", value = "2.5.6")
|
|
|
|
// no expected exception!
|
|
|
|
public void updateSamWithNullDriversLicenseSpring256() { |
|
|
|
public void updateSamWithNullDriversLicenseWithoutSessionFlush() { |
|
|
|
updateSamWithNullDriversLicense(); |
|
|
|
updateSamWithNullDriversLicense(); |
|
|
|
sessionFactory.getCurrentSession().flush(); |
|
|
|
// False positive, since an exception will be thrown once the session is
|
|
|
|
|
|
|
|
// finally flushed (i.e., in production code)
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Ignore("Disabled until SPR-5699 is resolved") |
|
|
|
|
|
|
|
@Test(expected = GenericJDBCException.class) |
|
|
|
@Test(expected = GenericJDBCException.class) |
|
|
|
// @Test(expected = UncategorizedSQLException.class)
|
|
|
|
public void updateSamWithNullDriversLicenseWithSessionFlush() { |
|
|
|
// @IfProfileValue(name = "spring-compatibility", value = "3.0.0.M2")
|
|
|
|
|
|
|
|
public void updateSamWithNullDriversLicenseSpring300() { |
|
|
|
|
|
|
|
updateSamWithNullDriversLicense(); |
|
|
|
updateSamWithNullDriversLicense(); |
|
|
|
|
|
|
|
// Manual flush is required to avoid false positive in test
|
|
|
|
|
|
|
|
sessionFactory.getCurrentSession().flush(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|