Thanks Chris for your detailed explanation. I am really excited about this project due to its expressiveness.
In fact, I had almost similar configuration. Here is the slightly updated code. I have added return statements to all the methods. I am not able to return from entityManagerFactory as LocalContainerEntityManagerFactoryBean does not belong to this type.
Code:
@Configuration
@AnnotationDrivenTx
@PropertiesValueSource(locations = "classpath:path/to/db.properties")
@Import(DataSourceConfig.class)
public abstract class JpaConfiguration {
abstract @ExternalValue("jdbc.showSql") boolean showSql();
abstract @ExternalValue("jdbc.generateDdl") boolean generateDdl();
abstract @ExternalValue("jdbc.databasePlatform") String databasePlatform();
abstract @ExternalBean DataSource dataSource();
public @Bean PersonDao personDao() {
PersonDaoImpl personDao = new PersonDaoImpl();
personDao.setEntityManagerFactory(entityManagerFactory());
return personDao;
}
public @Bean EntityManagerFactory entityManagerFactory() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setPersistenceUnitName("personPU");
em.setDataSource(dataSource());
em.setJpaVendorAdapter(jpaVendorAdapter());
return em;//incompatible types: required javax.persistence.EntityManagerFactory
}
public @Bean HibernateJpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setShowSql(showSql());
adapter.setGenerateDdl(generateDdl());
adapter.setDatabasePlatform(databasePlatform());
return adapter;
}
public @Bean PlatformTransactionManager transactionManager() {
JpaTransactionManager txManager = new JpaTransactionManager();
txManager.setEntityManagerFactory(entityManagerFactory());
txManager.setDataSource(dataSource());
return txManager;
}
}
I was trying to pull the snapshot using the following in my POM.
Code:
<repositories>
<!-- Necessary if using snapshot builds of SpringSource products (as above) -->
<repository>
<id>SpringSource Enterprise Bundle Repository - External Bundle Snapshots</id>
<url>repository.springsource.com/maven/bundles/snapshot</url>
</repository>
<!-- Required, as Spring JavaConfig has dependencies on released versions of SpringSource products -->
<repository>
<id>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</id>
<url>repository.springsource.com/maven/bundles/release</url>
</repository>
<!-- Required, as Spring JavaConfig has dependencies on External OSGi bundles -->
<repository>
<id>SpringSource Enterprise Bundle Repository - External Bundle Releases</id>
<url>repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>spring-milestone</id>
<name>Spring Milestone Repository</name>
<url>s3browse.com/explore/repository.springsource.com/maven/bundles/snapshot</url>
</repository>
</repositories>
<dependency>
<groupId>org.springframework.javaconfig</groupId>
<artifactId>org.springframework.config.java</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</dependency>
But, I could not fetch the snapshot from the maven repo defined above.
Am I missing something here?
[Note: I had intentionally removed the http prefix from the repository URLs because the forum posting does not allow me to include URL until I have made 15 posts.]