Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Spring Data repositories #122

Closed
aleksey-stukalov opened this issue Mar 20, 2020 · 0 comments
Closed

Support for Spring Data repositories #122

aleksey-stukalov opened this issue Mar 20, 2020 · 0 comments
Assignees
Milestone

Comments

@aleksey-stukalov
Copy link

aleksey-stukalov commented Mar 20, 2020

By using DataManager under the hood.

CUBA Prototype: https://github.com/cuba-rnd/cuba-jpa-repositories
https://www.cuba-platform.com/blog/spring-query-interfaces-in-cuba/

Done

  • (2d)Analyse, discuss
  • (1w)Move code to Jmix, make it work.
  • (3d) Refactor, move tests.
  • (1w3d) Deal with JpqlQueryGenerator implementaion.
  • (1w)Get rid of limitations (see readme in cuba-jpa-repositories).
  • (2d)Paging support
  • (2d)Finish test coverage
  • (3d)Packages/modules refactoring, UI dependency from data.
  • (1d+) Class Annotation to use UnsafeDataManagerImpl instead of DataManagerImpl
  • (2d) Implement repository proxy post processor in order to pass method metadata to CRUD repositories
  • (2d) Rework @Unsafe into @ApplyConstraints with spring-like logic
  • (summ: 2d) Improvements
    • (4h) Improve javadocs
    • (1d) Add boot autoconfiguration like org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration

Unfinished:

Usage:

Create interface that extends JmixDataRepository and add query methods you need:

  • use keywords from documentation to build your query name;
  • use io.jmix.core.repository.Query to explicitly specify jpql query:
    • named and positional parameters allowed,
    • special parameters like Pageable and Sort are not counted at positional parameters resolving process;
  • use io.jmix.core.repository.FetchPlan to specify fetch plan for loaded entities;
Example:

see data model at: https://github.com/Haulmont/jmix-data/tree/master/eclipselink/src/test/java/test_support/entity/repository
Repository:

public interface OrderRepository extends JmixDataRepository<SalesOrder, UUID> {

    List<SalesOrder> findByCustomerNameAndCustomerAddressCity(String name, String city);

    long countSalesOrdersByCustomer(Customer customer);

    boolean existsSalesOrdersByCustomerAddressCity(String city);

    void removeSalesOrdersByCustomerAddressCity(String city);

    List<SalesOrder> findSalesOrderByDateBeforeOrderByDateAsc(Date date);

    Page<SalesOrder> findByDateAfterAndNumberIn(Date date, Pageable pageable, List<String> numbers);

    @Query("select o from repository$SalesOrder o where (o.date> ?1 and o.number in ?2)")
    List<SalesOrder> findByQuery(Sort sort, Date date, List<String> numbers);

    @Query("select o from repository$SalesOrder o where (o.date> :date and o.number in :numbers)")
    Page<SalesOrder> findByQueryWithPaging(@Param("date") Date date,
                                                @Param("numbers") List<String> numbers,
                                                Pageable pageable);

    @FetchPlan("SalesOrder.full")
    List<SalesOrder> findByCustomerNotNullOrderByCustomerAddressCityAscDateAsc();
}
@knstvk knstvk changed the title Support Spring Data JPA repositories by using our own dataManager under the hood Support Spring Data repositories by using DataManager under the hood Mar 18, 2021
@knstvk knstvk transferred this issue from jmix-projects/jmix-old Mar 18, 2021
@knstvk knstvk changed the title Support Spring Data repositories by using DataManager under the hood Support for Spring Data repositories Mar 19, 2021
@knstvk knstvk added this to the 1.0.0 milestone Mar 24, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue May 17, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue May 20, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue May 20, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue May 20, 2021
dtaimanov added a commit to jmix-projects/jmix-security that referenced this issue May 25, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue May 25, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 8, 2021
dtaimanov added a commit that referenced this issue Jun 8, 2021
dtaimanov added a commit that referenced this issue Jun 8, 2021
@dtaimanov dtaimanov reopened this Jun 8, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 10, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 10, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 11, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 15, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 15, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 15, 2021
dtaimanov added a commit that referenced this issue Jun 15, 2021
dtaimanov added a commit that referenced this issue Jun 15, 2021
dtaimanov added a commit that referenced this issue Jun 15, 2021
dtaimanov added a commit that referenced this issue Jun 15, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 15, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 15, 2021
dtaimanov added a commit to jmix-projects/jmix-data that referenced this issue Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants