If you do not want to expose so many methods, you can customize their own repository, but also in their own repository to add their own public methods of course more flexible is to write an implementation class to achieve their own Method 1: Write a class with the same name as the interface, The suffix is impl, which is configured in the previous XML and can be scanned automatically. This class does not need to implement any interfaces. 2: In the interface to add their own methods, such as: Public page<object[]> getbycondition (Userquerymodel u); 3: In the implementation class, to implement this method is good, will be automatically found
Java code:
@PersistenceContext private Entitymanager em; Public page<object[]> getbycondition (Userquerymodel u) { String hql = ' Select O.uuid,o.name from Usermodel o whe Re 1=1 and O.uuid=:uuid "; Query q = em.createquery (HQL); Q.setparameter ("UUID", U.getuuid ()); Q.setfirstresult (0); Q.setmaxresults (1); page<object[]> page = new pageimpl<object[]> (Q.getresultlist (), New Pagerequest (0,1), 3); return page; }}
Spring data implements a custom repository implementation class that implements the JPA