jpa work
This commit is contained in:
parent
dbd5616f5a
commit
71a230ef91
|
@ -40,11 +40,7 @@ public class PersistenceConfig {
|
||||||
factoryBean.setDataSource(restDataSource());
|
factoryBean.setDataSource(restDataSource());
|
||||||
factoryBean.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" });
|
factoryBean.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" });
|
||||||
|
|
||||||
final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter() {
|
final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
||||||
{
|
|
||||||
// JPA properties ...
|
|
||||||
}
|
|
||||||
};
|
|
||||||
factoryBean.setJpaVendorAdapter(vendorAdapter);
|
factoryBean.setJpaVendorAdapter(vendorAdapter);
|
||||||
factoryBean.setJpaProperties(additionalProperties());
|
factoryBean.setJpaProperties(additionalProperties());
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@ public class FooDao implements IFooDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final Foo entity) {
|
public Foo update(final Foo entity) {
|
||||||
Preconditions.checkNotNull(entity);
|
Preconditions.checkNotNull(entity);
|
||||||
entityManager.merge(entity);
|
return entityManager.merge(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,7 +12,7 @@ public interface IFooDao {
|
||||||
|
|
||||||
void create(Foo entity);
|
void create(Foo entity);
|
||||||
|
|
||||||
void update(Foo entity);
|
Foo update(Foo entity);
|
||||||
|
|
||||||
void delete(Foo entity);
|
void delete(Foo entity);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||||
|
|
||||||
import org.baeldung.spring.persistence.config.PersistenceConfig;
|
import org.baeldung.spring.persistence.config.PersistenceConfig;
|
||||||
import org.baeldung.spring.persistence.model.Foo;
|
import org.baeldung.spring.persistence.model.Foo;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -51,9 +50,8 @@ public class FooServicePersistenceIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public final void temp_whenInvalidEntityIsCreated_thenDataException() {
|
public final void temp_whenInvalidEntityIsCreated_thenDataException() {
|
||||||
service.create(new Foo(randomAlphabetic(2048)));
|
service.create(new Foo());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue