Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mivui/jpa-querydsl-spring-boot-starter
https://github.com/mivui/jpa-querydsl-spring-boot-starter
jpa querydsl spring-boot spring-data-jpa
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mivui/jpa-querydsl-spring-boot-starter
- Owner: mivui
- License: apache-2.0
- Created: 2020-05-18T01:18:02.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-11T03:15:09.000Z (over 3 years ago)
- Last Synced: 2024-11-15T06:48:37.512Z (3 months ago)
- Topics: jpa, querydsl, spring-boot, spring-data-jpa
- Language: Java
- Homepage:
- Size: 90.8 KB
- Stars: 5
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jpa-querydsl-spring-boot-starter
English | [中文](./ZH_CN.md)
* Jpa Quick Design
* Support spring boot 2.1.x and above (including 2.1.x)### Introduction
* Jpa Service CRUD package, support querydsl out of the box.
### use
1. Add dependency
```xml
com.github.uinio
jpa-querydsl-spring-boot-starter
2.5.1
```----------
2. examples
* Entity class
```java
@Table
@Entity
public class Contact implements Serializable {@Id
private Integer id;private Name name;
private String notes;
//getter setter ...
}
```---------
> Repository```java
public interface ContactRepository extends JpaRepository {}
```--------
> service* Provide single table CURD operation.
* Note: The provided JpaService only supports single table operations, and complex operations use EntityManager or
QueryDsl```java
public interface ContactService extends JpaService {
}
```--------
```java
@Service
public class ContactServiceImpl extends JpaServiceImpl implements UserService {}
```-------
> Test```java
@SpringBootTest
class MainApplicationTests {@Autowired
private ContactService contactService;@Test
void contextLoads() {
//Insert
Contact contact = new Contact();
contact.setName("test");
contact.setNotes("test");
contactService.save(contact);//Update
Contact contact = new Contact();
contact.setId(1);
contact.setName("example");
contact.setNotes("example");
contactService.update(contact);//Delete
contactService.deleteById(1);//BatchDeletion
contactService.deleteByIds(new Integer[]{1, 2});//Pagination
contactService.page(1, 2);//...
}
}
```-------
> querydsl out of the box* configuration
```xml
org.springframework.boot
spring-boot-maven-plugin
com.mysema.maven
apt-maven-plugin
1.1.3
process
target/generated-sources/java
com.querydsl.apt.jpa.JPAAnnotationProcessor
com.querydsl
querydsl-apt
${querydsl.version}
```
* mvn compile generate query class
```java
@SpringBootTest
class MainApplicationTests {@Autowired
private JPAQueryFactory jpaQueryFactory;@Test
void contextLoads() {
QContact contact = QContact.contact;
jpaQueryFactory.update(contact).set(contact.name, "test")
.where(contact.id.eq(1)).execute();
}}
```