Java-65 split persistence-modules/spring-jpa
This commit is contained in:
-24
@@ -1,24 +0,0 @@
|
||||
package com.baeldung.manytomany;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = ManyToManyTestConfiguration.class)
|
||||
@DirtiesContext
|
||||
public class ManyToManyIntegrationTest {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
|
||||
@Test
|
||||
public void contextStarted() {
|
||||
}
|
||||
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
package com.baeldung.manytomany;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
import org.springframework.orm.jpa.JpaVendorAdapter;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:/manytomany/test.properties")
|
||||
public class ManyToManyTestConfiguration {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder();
|
||||
return dbBuilder.setType(EmbeddedDatabaseType.H2)
|
||||
.addScript("classpath:/manytomany/db.sql")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Value("${hibernate.hbm2ddl.auto}") String hbm2ddlType, @Value("${hibernate.dialect}") String dialect, @Value("${hibernate.show_sql}") boolean showSql) {
|
||||
LocalContainerEntityManagerFactoryBean result = new LocalContainerEntityManagerFactoryBean();
|
||||
|
||||
result.setDataSource(dataSource());
|
||||
result.setPackagesToScan("com.baeldung.manytomany.model");
|
||||
result.setJpaVendorAdapter(jpaVendorAdapter());
|
||||
|
||||
Map<String, Object> jpaProperties = new HashMap<>();
|
||||
jpaProperties.put("hibernate.hbm2ddl.auto", hbm2ddlType);
|
||||
jpaProperties.put("hibernate.dialect", dialect);
|
||||
jpaProperties.put("hibernate.show_sql", showSql);
|
||||
result.setJpaPropertyMap(jpaProperties);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public JpaVendorAdapter jpaVendorAdapter() {
|
||||
return new HibernateJpaVendorAdapter();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user