persistence cleanup

This commit is contained in:
eugenp
2014-01-25 15:28:38 +02:00
parent 0d5f88e206
commit 29f02a2a8b
4 changed files with 21 additions and 7 deletions
@@ -1,4 +1,4 @@
package org.baeldung.spring;
package org.baeldung.config;
import java.util.Properties;
@@ -8,6 +8,7 @@ import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
@@ -20,7 +21,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.google.common.base.Preconditions;
// @Configuration
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-mysql.properties" })
@ComponentScan({ "org.baeldung.persistence" })
@@ -33,6 +34,8 @@ public class PersistenceJPAConfig {
super();
}
// beans
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
@@ -40,7 +43,6 @@ public class PersistenceJPAConfig {
em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
// vendorAdapter.set
em.setJpaVendorAdapter(vendorAdapter);
em.setJpaProperties(additionalProperties());
@@ -1,11 +1,10 @@
package org.baeldung.spring;
package org.baeldung.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
// @Configuration
@EnableTransactionManagement
@ComponentScan({ "org.baeldung.persistence" })
@ImportResource({ "classpath:jpaConfig.xml" })
@@ -23,4 +23,8 @@ public class FooService {
dao.create(entity);
}
public Foo findOne(final long id) {
return dao.findOne(id);
}
}