cleanup of examples
This commit is contained in:
parent
5a1c890c10
commit
14c76d379a
|
@ -1,23 +0,0 @@
|
|||
package org.baeldung.ex.mappingexception.cause1.persistence.dao;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo;
|
||||
import org.baeldung.persistence.common.AbstractHibernateDao;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class FooDao extends AbstractHibernateDao<Foo> implements IFooDao {
|
||||
|
||||
@Autowired
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
public FooDao() {
|
||||
super();
|
||||
|
||||
setClazz(Foo.class);
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package org.baeldung.ex.mappingexception.cause1.persistence.dao;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo;
|
||||
import org.baeldung.persistence.common.IOperations;
|
||||
|
||||
public interface IFooDao extends IOperations<Foo> {
|
||||
//
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package org.baeldung.ex.mappingexception.cause1.persistence.service;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause1.persistence.dao.IFooDao;
|
||||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo;
|
||||
import org.baeldung.persistence.common.AbstractService;
|
||||
import org.baeldung.persistence.common.IOperations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FooService extends AbstractService<Foo> implements IFooService {
|
||||
|
||||
@Autowired
|
||||
private IFooDao dao;
|
||||
|
||||
public FooService() {
|
||||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
@Override
|
||||
protected IOperations<Foo> getDao() {
|
||||
return dao;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package org.baeldung.ex.mappingexception.cause1.persistence.service;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo;
|
||||
import org.baeldung.persistence.common.IOperations;
|
||||
|
||||
public interface IFooService extends IOperations<Foo> {
|
||||
//
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package org.baeldung.ex.mappingexception.cause2.persistence.dao;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo;
|
||||
import org.baeldung.persistence.common.AbstractHibernateDao;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class FooDao extends AbstractHibernateDao<Foo> implements IFooDao {
|
||||
|
||||
@Autowired
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
public FooDao() {
|
||||
super();
|
||||
|
||||
setClazz(Foo.class);
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package org.baeldung.ex.mappingexception.cause2.persistence.dao;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo;
|
||||
import org.baeldung.persistence.common.IOperations;
|
||||
|
||||
public interface IFooDao extends IOperations<Foo> {
|
||||
//
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package org.baeldung.ex.mappingexception.cause2.persistence.service;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause2.persistence.dao.IFooDao;
|
||||
import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo;
|
||||
import org.baeldung.persistence.common.AbstractService;
|
||||
import org.baeldung.persistence.common.IOperations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FooService extends AbstractService<Foo> implements IFooService {
|
||||
|
||||
@Autowired
|
||||
private IFooDao dao;
|
||||
|
||||
public FooService() {
|
||||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
@Override
|
||||
protected IOperations<Foo> getDao() {
|
||||
return dao;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package org.baeldung.ex.mappingexception.cause2.persistence.service;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo;
|
||||
import org.baeldung.persistence.common.IOperations;
|
||||
|
||||
public interface IFooService extends IOperations<Foo> {
|
||||
//
|
||||
}
|
|
@ -3,27 +3,29 @@ package org.baeldung.ex.mappingexception;
|
|||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo;
|
||||
import org.baeldung.ex.mappingexception.cause1.persistence.service.IFooService;
|
||||
import org.baeldung.ex.mappingexception.spring.Cause1PersistenceConfig;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Cause1PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class Cause1MappingExceptionIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private IFooService fooApi;
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
// tests
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public final void givenEntityIsPersisted_thenException() {
|
||||
fooApi.create(new Foo(randomAlphabetic(6)));
|
||||
sessionFactory.getCurrentSession().saveOrUpdate(new Foo(randomAlphabetic(6)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,27 +3,29 @@ package org.baeldung.ex.mappingexception;
|
|||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||
|
||||
import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo;
|
||||
import org.baeldung.ex.mappingexception.cause2.persistence.service.IFooService;
|
||||
import org.baeldung.ex.mappingexception.spring.Cause2PersistenceConfig;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Cause2PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class Cause2MappingExceptionIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private IFooService fooApi;
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
// tests
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public final void givenEntityIsPersisted_thenException() {
|
||||
fooApi.create(new Foo(randomAlphabetic(6)));
|
||||
sessionFactory.getCurrentSession().saveOrUpdate(new Foo(randomAlphabetic(6)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue