package jp.hashiwa.accountbook;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ABService {
  @Autowired
  ABRepository repository;

  public List<ABItem> selectAll() {
    return repository.findAll(new Sort(Sort.Direction.ASC, "id"));
  }

  public ABItem select(long id) {
    return repository.findById(id);
  }

  public void saveAndFlush(ABItem item) {
    repository.saveAndFlush(item);
  }

  public void delete(long id) {
    repository.delete(id);
  }
}

@@ -320,16 +320,96 @@
 rvice %7B%0A
+  private static final Sort SORT = new Sort(Sort.Direction.ASC, %22date%22, %22id%22);%0A%0A
   @Autow
@@ -511,42 +511,12 @@
 All(
-new Sort(Sort.Direction.ASC, %22id%22)
+SORT
 );%0A 

change sort key