persistence work
This commit is contained in:
parent
011d6a1f78
commit
7cbbf265f9
|
@ -35,7 +35,7 @@ public abstract class AbstractHibernateDao<T extends Serializable> implements IO
|
|||
@Override
|
||||
public final void create(final T entity) {
|
||||
Preconditions.checkNotNull(entity);
|
||||
getCurrentSession().save(entity);
|
||||
getCurrentSession().persist(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package org.baeldung.spring.persistence.service;
|
||||
|
||||
import org.baeldung.spring.persistence.dao.common.IOperations;
|
||||
import org.baeldung.spring.persistence.model.Foo;
|
||||
|
||||
public interface IFooService extends IOperations<Foo> {
|
||||
//
|
||||
}
|
|
@ -4,7 +4,9 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.persistence.dao.common.IOperations;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Transactional
|
||||
public abstract class AbstractService<T extends Serializable> implements IOperations<T> {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.baeldung.spring.persistence.service.impl;
|
|||
import org.baeldung.spring.persistence.dao.IFooDao;
|
||||
import org.baeldung.spring.persistence.dao.common.IOperations;
|
||||
import org.baeldung.spring.persistence.model.Foo;
|
||||
import org.baeldung.spring.persistence.service.IFooService;
|
||||
import org.baeldung.spring.persistence.service.common.AbstractService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -10,7 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
@Service
|
||||
@Transactional
|
||||
public class FooService extends AbstractService<Foo> {
|
||||
public class FooService extends AbstractService<Foo> implements IFooService {
|
||||
|
||||
@Autowired
|
||||
private IFooDao dao;
|
||||
|
|
|
@ -4,7 +4,6 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
|||
|
||||
import org.baeldung.spring.persistence.config.PersistenceConfig;
|
||||
import org.baeldung.spring.persistence.model.Foo;
|
||||
import org.baeldung.spring.persistence.service.impl.FooService;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -20,7 +19,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
|||
public class FooServicePersistenceIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private FooService service;
|
||||
private IFooService service;
|
||||
|
||||
// tests
|
||||
|
||||
|
|
Loading…
Reference in New Issue