Springboot+jpa simply builds the environment

1. Packages that may be needed: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>jakarta.persistence</groupId> <artifactId>jakarta.persistence-api</artifactId> <version>2.2.3</version> </dependency> <!– jap configuration –> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> <version>2.3.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> 2. Environment preparation jdk 8 IDEA 2020 mysql 8 3. Simple use 1. Sorting of springboot JPA built-in sorting and paging: Sort sort =Sort.by(Sort.Direction.ASC,”id”); //Due to version […]

Example of custom SQL statements using case/when statements to implement paging queries and classification sorting in JPA programming

1. Requirement background Query the list of work orders initiated by me and invited by me. It requires paging query. The specific requirements for sorting are: Sort by status first, with unprocessed items at the front Then sort by handler, those who were invited are ranked first, and those who initiated themselves are ranked last. […]

SpringBoot integrates JPA to implement paging and CRUD

SpringBoot integrates JPA to implement paging and CRUD Article directory SpringBoot integrates JPA to implement paging and CRUD pom.xml application.properties addCategory.jsp editCategory.jsp hello.jsp listCategory.jsp Category CategoryDAO CategoryService CategoryServiceImpl Page4Navigator RedisConfig CategoryController HelloController Too lazy to type the code, just copy: SpringBoot integrates JPA to implement paging and CRUD pom.xml <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” […]

Let’s talk briefly about JPA and SpringDataJPA

1.What is JPA? The full name of JPA is the abbreviation of Java Persistence API. The Chinese name is: java persistence layer API. It is the mapping relationship between JDK5.0 annotations or XML description objects and relational tables, and persists the test object of the runner into the database. It can be understood as , […]

“Java Development Guide” How to use JPA and Spring to manage transactions in MyEclipse? (two)

This tutorial introduces some JPA/spring-based features, focusing on JPA-Spring integration and how to take advantage of these features. You’ll learn how to: Set up a project for JPA and Spring Reverse engineer database tables to generate entities Implement creation, retrieval, editing and deletion functions Enable container-managed transactions In the above (>”>Click here to review>>), we […]

springboot integrates mybatis, mybatisplus, jpa, druid data source, jsp template engine

1springboot integrates jsp template engine To create a springboot project, select several common dependencies, such as lombook and spring web dependencies, etc. Because jsp is not integrated in the srpingboot project, import the following jsp dependencies into the pom file in the springboot project: <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> Then click project Structure Click modules, […]

SpringBoot integrates ElasticSearch (different dependencies, business code and JPA methods are also different)

Framework: springboot + gradle 1. Introduce dependencies implementation(“org.elasticsearch:elasticsearch:7.6.1”) implementation(“org.elasticsearch.client:elasticsearch-rest-high-level-client:7.6.1”) 2. Configure application elasticsearch: username: elastic password: elastic uris: localhost:9200 3. Configuration file @Configuration @RequiredArgsConstructor public class ElasticsearchConfig{ public static ObjectMapper objectMapper = new ObjectMapper(); @Bean(“restHighLevelClient”) public RestHighLevelClient elasticsearchClient(ElasticsearchProperties elasticsearchProperties){ final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(elasticsearchProperties.getUsername(), elasticsearchProperties.getPassword())); RestClientBuilder restClientBuilder = RestClient.builder(HttpHost.create(elasticsearchProperties.getUris().get(0))) .setHttpClientConfigCallback(httpAsyncClientBuilder -> […]

Development environment construction based on SpringBoot framework: use of SpringData JPA

The previous article has described how to build a Springboot environment and integrate mysql database Development environment construction based on SpringBoot framework: project creation + integrated database 3. Query operation of SpringData JPA SpringData JPA has 5 core interfaces: Repository: It is the top-level interface. It is an empty interface. The purpose is to unify […]

Simple JPA implementation of RBAC model-single table and multi-table query

Table of Contents concept Specific implementation of JPA 1. Introduce dependencies 2. Domain module configuration yml file 3. Entity class (take permission table as an example) 4. User module configuration yml file 5. Dao layer interface 6. Service layer interface and implementation class (take UserService as an example) 7. Controller control layer 8. Unit testing […]