Results 1 to 2 of 2

Thread: Unable to add custom methods to Spring Data repository generated by Roo

Threaded View

  1. #1
    Join Date
    Feb 2013
    Posts
    5

    Default Unable to add custom methods to Spring Data repository generated by Roo

    Using the script below, Roo generates repository/DAO layer containing Book.java (javabean), BookRepository.java (interface), and some .aj files (Non-editable).

    Code:
    ...
    entity jpa --class ~.Book --activeRecord false
    field date --fieldName rentalDate --type java.util.Date
    field number --fieldName isbn --type java.lang.Integer
    field string --fieldName title
    repository jpa --interface ~.BookRepository
    I package the DAO layer as .jar file and I use it as follow on another project (Without Spring Roo):
    Code:
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath*:META-INF/spring/applicationContext*.xml");
    
    BookRepository bookRepo = (BookRepository)springContext.getBean("BookRepository");
    bookRepo.saveAndFlush(entity);
    Now, I need to introduce custom methods to perform more complex data access but I want to keep access still coming from the same interface, eg.
    Code:
    bookRepo.doSomething(bookId)
    However, I do not know where to put the implementation of the method since there is no Java class where I can put the implementation (I only have Book.java and BookRepository.java), furthermore BookRepository.java demands me to specify @Query.

    If you have thought about this scenario when designing Spring Roo, please help.
    Thank you.
    Last edited by cix.yong; Feb 16th, 2013 at 03:02 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •