Remove Item
This commit is contained in:
11
pom.xml
11
pom.xml
@@ -54,17 +54,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- QueryDSL APT Config -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.querydsl</groupId>
|
|
||||||
<artifactId>querydsl-apt</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- QueryDSL JPA Config -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.querydsl</groupId>
|
|
||||||
<artifactId>querydsl-jpa</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.security.basic.configure;
|
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import javax.persistence.PersistenceContext;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableJpaAuditing
|
|
||||||
public class JpaConfiguration {
|
|
||||||
|
|
||||||
@PersistenceContext
|
|
||||||
private EntityManager em;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public JPAQueryFactory jpaQueryFactory () {
|
|
||||||
return new JPAQueryFactory(em);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.security.basic.mapped;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
|
|
||||||
@MappedSuperclass
|
|
||||||
public abstract class BaseItem {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "id", nullable = false)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Column(name = "name", nullable = false)
|
|
||||||
private String name;
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.security.basic.mapped;
|
|
||||||
|
|
||||||
import com.querydsl.core.types.Projections;
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Repository
|
|
||||||
public class BaseItemRepository {
|
|
||||||
|
|
||||||
private final JPAQueryFactory queryFactory;
|
|
||||||
|
|
||||||
com.security.basic.mapped.QBaseItem qItemA = com.security.basic.mapped.QItemA.itemA._super;
|
|
||||||
com.security.basic.mapped.QBaseItem qItemB = com.security.basic.mapped.QItemB.itemB._super;
|
|
||||||
|
|
||||||
public List<ItemDto> itemAList() {
|
|
||||||
return queryFactory.select(Projections.constructor(ItemDto.class,
|
|
||||||
qItemA.id,
|
|
||||||
qItemA.name
|
|
||||||
))
|
|
||||||
.from(qItemA)
|
|
||||||
.fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ItemDto> itemBList() {
|
|
||||||
return queryFactory.select(Projections.constructor(ItemDto.class,
|
|
||||||
qItemB.id,
|
|
||||||
qItemB.name
|
|
||||||
))
|
|
||||||
.from(qItemB)
|
|
||||||
.fetch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.security.basic.mapped;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RequestMapping("/mapped")
|
|
||||||
public class Controller {
|
|
||||||
|
|
||||||
private final BaseItemRepository baseItemRepository;
|
|
||||||
|
|
||||||
@GetMapping("/a")
|
|
||||||
public ResponseEntity<?> a() {
|
|
||||||
return ResponseEntity.ok(baseItemRepository.itemAList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/b")
|
|
||||||
public ResponseEntity<?> b() {
|
|
||||||
return ResponseEntity.ok(baseItemRepository.itemBList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.security.basic.mapped;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class ItemA extends BaseItem{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package com.security.basic.mapped;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
@Table(name = "item_a")
|
|
||||||
@Entity
|
|
||||||
public class ItemB extends BaseItem{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package com.security.basic.mapped;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class ItemDto {
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
private String name;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user