In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Most people do not understand the knowledge points of this article "how to use Service class", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use Service class" article.
Service is used to handle business logic and to invoke DAO to manipulate the database.
Configuration file
The Service of the system is configured in @ ComponentScan ({"com.jspxcms.core.service.impl", "com.jspxcms.ext.service.impl"}) of com.jspxcms.core.ContextConfig.
The Service for this example is configured in @ ComponentScan ({"com.jspxcms.plug.service.impl"}) of com.jspxcms.plug.ContextConfig.
Service class package com.jspxcms.plug.service.impl;@Service@Transactional (readOnly = true) public class ResumeServiceImpl implements ResumeService {public Page findAll (Integer siteId,Map params, Pageable pageable) {return dao.findAll (spec (siteId, params), pageable);} public RowSide findSide (Integer siteId,Map params, Resume bean, Integer position, Sort sort) {if (position = = null) {return new RowSide () } Limitable limit = RowSide.limitable (position, sort); List list = dao.findAll (spec (siteId, params), limit); return RowSide.create (list, bean);} private Specification spec (final Integer siteId, Map params) {Collection filters = SearchFilter.parse (params). Values (); final Specification fsp = SearchFilter.spec (filters, Resume.class) Specification sp = new Specification () {public Predicate toPredicate (Root root, CriteriaQuery query, CriteriaBuilder cb) {Predicate pred = fsp.toPredicate (root, query, cb); if (siteId! = null) {pred = cb.and (pred, cb.equal (root.get ("site"). Get ("id"), siteId);} return pred;}}; return sp;} private ResumeDao dao; @ Autowired public void setDao (ResumeDao dao) {this.dao = dao;}}
This class uses the Specification query method to JPA. The background list can be sorted by any column by clicking on the header, the list page can be queried by any field, and the function of editing one or the next item on the page can be realized.
The above is about the content of this article "how to use the Service class". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.