persistence work

This commit is contained in:
eugenp 2013-05-18 17:01:26 +03:00
parent 011d6a1f78
commit 7cbbf265f9
5 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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> {
//
}

View File

@ -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

View File

@ -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;

View File

@ -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