From 2bde87bef2a973d1c9b3fabe6c59db5f7ebc1fcd Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 17:14:49 +0300 Subject: [PATCH] new owner - child support --- .../persistence/service/IChildService.java | 8 ++++++ .../persistence/service/IOwnerService.java | 8 ++++++ .../service/impl/ChildService.java | 28 +++++++++++++++++++ .../service/impl/OwnerService.java | 28 +++++++++++++++++++ ...wnerServicePersistenceIntegrationTest.java | 28 +++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java create mode 100644 spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java new file mode 100644 index 0000000000..785d581c79 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java @@ -0,0 +1,8 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Child; + +public interface IChildService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java new file mode 100644 index 0000000000..66e647b253 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java @@ -0,0 +1,8 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Owner; + +public interface IOwnerService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java new file mode 100644 index 0000000000..d28682fdfd --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java @@ -0,0 +1,28 @@ +package org.baeldung.spring.persistence.service.impl; + +import org.baeldung.spring.persistence.dao.IChildDao; +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Child; +import org.baeldung.spring.persistence.service.IChildService; +import org.baeldung.spring.persistence.service.common.AbstractService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ChildService extends AbstractService implements IChildService { + + @Autowired + private IChildDao dao; + + public ChildService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java new file mode 100644 index 0000000000..e3f2f7a04f --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java @@ -0,0 +1,28 @@ +package org.baeldung.spring.persistence.service.impl; + +import org.baeldung.spring.persistence.dao.IOwnerDao; +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Owner; +import org.baeldung.spring.persistence.service.IOwnerService; +import org.baeldung.spring.persistence.service.common.AbstractService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class OwnerService extends AbstractService implements IOwnerService { + + @Autowired + private IOwnerDao dao; + + public OwnerService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java new file mode 100644 index 0000000000..4b668777a8 --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java @@ -0,0 +1,28 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.config.PersistenceConfig; +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; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class OwnerServicePersistenceIntegrationTest { + + @Autowired + private IOwnerService service; + + @Autowired + private IChildService childService; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + +}