From 71a230ef91dac7ec3a954389ca8001d53814a3e0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 15:54:43 +0300 Subject: [PATCH] jpa work --- .../spring/persistence/config/PersistenceConfig.java | 6 +----- .../java/org/baeldung/spring/persistence/dao/FooDao.java | 4 ++-- .../java/org/baeldung/spring/persistence/dao/IFooDao.java | 2 +- .../service/FooServicePersistenceIntegrationTest.java | 4 +--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index 3532afe229..52ee113e17 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -40,11 +40,7 @@ public class PersistenceConfig { factoryBean.setDataSource(restDataSource()); factoryBean.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); - final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter() { - { - // JPA properties ... - } - }; + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); factoryBean.setJpaVendorAdapter(vendorAdapter); factoryBean.setJpaProperties(additionalProperties()); diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java index 8f9b5003da..f970ade71f 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -40,9 +40,9 @@ public class FooDao implements IFooDao { } @Override - public void update(final Foo entity) { + public Foo update(final Foo entity) { Preconditions.checkNotNull(entity); - entityManager.merge(entity); + return entityManager.merge(entity); } @Override diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java index a5c22d1e41..201fc3e351 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -12,7 +12,7 @@ public interface IFooDao { void create(Foo entity); - void update(Foo entity); + Foo update(Foo entity); void delete(Foo entity); diff --git a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 576f536adc..42dbb45f03 100644 --- a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -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.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -51,9 +50,8 @@ public class FooServicePersistenceIntegrationTest { } @Test - @Ignore public final void temp_whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); + service.create(new Foo()); } }