Spring Data JPA & MyBatis

25,620

Solution 1

Mybatis does not implement JPA. Mybatis is not ORM Framework. JPA is ORM Specification which is implemented by Hibernate, Toplink, Eclipselink . Since Mybatis does not mplement JPA, it does not come under the list of JPA providers. Hence, you cannot use mybatis as a JPA framework. Mybatis is a data mapper framework which is completely different framework compared to JPA. In JPA and ORM frameworks, you map Objects /Entities to the corresponding sql tables and you work on objects and not on tables directly unless you use their native queries. In mybatis , you play directly with sql data.. Hope this clears the difference between mybatis and JPA. Hence when you want mybatis with spring data you use spring data mybatis independently and not spring data JPA.

Solution 2

Why not try spring-data-jpa-extra

It provide a dynamic query solution for spring-data-jpa like mybatis, but much easier than mybatis.

I think you would like it : )

Solution 3

Spring-Data-Mybatis Hatunet version

I am using this project: https://github.com/hatunet/spring-data-mybatis

It fit very well with spring-data-mybatis and it have also the paginated repository.

Work very well on production project.

update 08/2020

The projet as moved to another webspace and evolved: https://github.com/easybest/spring-data-mybatis

Share:
25,620
srini
Author by

srini

Updated on August 11, 2020

Comments

  • srini
    srini over 3 years

    I am trying to use Spring Data JPA with MyBatis. Since there isnt a Vendor Adapter for MyBatis, what is the alternative here?

    <bean id="entityManagerFactory"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="com.abc.xyz.domain"/>
    </bean>
    

    I am getting the below exception when I tried to initialize my application.

    Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No PersistenceProvider specified in EntityManagerFactory configuration, and chosen PersistenceUnitInfo does not specify a provider class name either
    

    Thanks

  • Dimitri Kopriwa
    Dimitri Kopriwa over 3 years
    I updated the repository link since the new version is now om easyJet namespace. The project is stable.