Impetus / kundera

A JPA 2.1 compliant Polyglot Object-Datastore Mapping Library for NoSQL Datastores.Please subscribe to:
http://groups.google.com/group/kundera-discuss/subscribe
Apache License 2.0
903 stars 234 forks source link

would you consider to add a tutorial with kundera and spring boot ? #1006

Open bedinsky opened 6 years ago

bedinsky commented 6 years ago

this tutorial on kundera spring does not help with spring boot https://github.com/Impetus/Kundera/wiki/Building-Applications-with-Kundera-and-Spring

I'm trying to start a spring boot application with jpa using kundera but I do not find out what to write in "Application Properties File"

Eventually I have disable datasource auto configuration and instantiated a EntityManagerFactoryBean

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
devender-yadav commented 6 years ago

Hi @bedinsky,

We will plan to add a tutorial on this soon. Meanwhile, we appreciate if any community member wants to contribute to this.

As of now, you can keep applicationContext.xml file and use

@ImportResource("classpath:applicationContext.xml") in your SpringBootApplication class.

bedinsky commented 6 years ago

Hi, thank you for answering ! I do not use applicationContex.xml Here is my example if someone prefers programmatic configuration. persistence.xml is mandatory in classpath

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
@SpringBootApplication
public class Application 
{
    public static void main(String[] args) {
          new SpringApplicationBuilder(Application.class)
          .sources(PersistenceJPAConfig.class)
          .logStartupInfo(true)
          .build()
          .run(args);       
    }
}
@Configuration
@EnableTransactionManagement(order=10)
@ComponentScan({ "yourpackage.persistence" })
public class PersistenceJPAConfig {

    public PersistenceJPAConfig() {
        super();
    }

    @PostConstruct
    public void init() {
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
        final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
        factoryBean.setPersistenceUnitName("cassandra_pu");
        return factoryBean;
    }

    @Bean
    public PlatformTransactionManager transactionManager(
            final EntityManagerFactory emf) {
        final JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManager.setEntityManagerFactory(emf);
        return transactionManager;
    }   
}