persistence work
This commit is contained in:
parent
380e14bff0
commit
f9712c2db4
|
@ -2,12 +2,10 @@ package org.baeldung.ex.mappingexception.cause1.persistence.model;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Foo implements Serializable {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -35,9 +35,11 @@ public class Cause2PersistenceConfig {
|
|||
public LocalSessionFactoryBean sessionFactory() {
|
||||
final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
|
||||
sessionFactory.setDataSource(restDataSource());
|
||||
sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model2" });
|
||||
sessionFactory.setHibernateProperties(hibernateProperties());
|
||||
|
||||
// sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model" });
|
||||
// sessionFactory.setAnnotatedClasses(new Class[] { Foo.class });
|
||||
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,11 @@ public class Cause3PersistenceConfig {
|
|||
public LocalSessionFactoryBean sessionFactory() {
|
||||
final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
|
||||
sessionFactory.setDataSource(restDataSource());
|
||||
sessionFactory.setAnnotatedClasses(new Class[] { Foo.class });
|
||||
sessionFactory.setHibernateProperties(hibernateProperties());
|
||||
|
||||
// sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model" });
|
||||
sessionFactory.setAnnotatedClasses(new Class[] { Foo.class });
|
||||
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.baeldung.ex.mappingexception;
|
|||
|
||||
import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo;
|
||||
import org.baeldung.ex.mappingexception.spring.Cause2PersistenceConfig;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -21,7 +20,8 @@ public class Cause2MappingExceptionIntegrationTest {
|
|||
|
||||
// tests
|
||||
|
||||
@Test(expected = MappingException.class)
|
||||
// @Test(expected = MappingException.class)
|
||||
@Test
|
||||
@Transactional
|
||||
public final void givenEntityIsPersisted_thenException() {
|
||||
sessionFactory.getCurrentSession().saveOrUpdate(new Foo());
|
||||
|
|
Loading…
Reference in New Issue