Field Types Reference
Overview
ElastiCORE DSL은 다양한 필드 타입을 지원하며, 각 타입은 해당하는 Java 타입과 JPA 컬럼 매핑으로 자동 변환됩니다.
String Types
string(n)
- Java 타입:
String - JPA 매핑:
@Column(length = n) - Description: 지정된 최대 길이의 문자열
- NOT NULL:
!접미사 추가 (예:string(100)!)
name: string(100) # VARCHAR(100), nullable
email: string(255)! # VARCHAR(255), NOT NULL
text
- Java 타입:
String - JPA 매핑:
@Column(columnDefinition = "TEXT")또는@Lob - Description: 긴 텍스트 (제한 없음)
content: text # TEXT 타입
description: text # 긴 설명 필드
Numeric Types
int / Integer
- Java 타입:
int(primitive) /Integer(wrapper) - JPA 매핑:
@Column - Description: 32비트 정수
age: int # int (primitive)
count: Integer # Integer (wrapper, nullable)
long / Long
- Java 타입:
long(primitive) /Long(wrapper) - JPA 매핑:
@Column - Description: 64비트 정수
id: long @id @sequence # 기본키로 자주 사용
totalCount: Long # Long (wrapper, nullable)
double / Double
- Java 타입:
double(primitive) /Double(wrapper) - JPA 매핑:
@Column - Description: 64비트 부동소수점
price: double # 가격 (부동소수점)
rating: Double # 평점 (nullable)
bigdecimal(precision.scale)
- Java 타입:
BigDecimal - JPA 매핑:
@Column(precision = p, scale = s) - Description: 고정소수점 숫자 (금융 데이터에 권장)
amount: bigdecimal(15.2) # precision=15, scale=2
rate: bigdecimal(10.4) # precision=10, scale=4
salary: bigdecimal(12.2) # 급여 (정밀도 12, 소수점 2자리)
팁
금융 데이터나 정밀한 계산이 필요한 경우 double 대신 bigdecimal을 사용하세요.
Boolean Types
boolean / Boolean
- Java 타입:
boolean(primitive) /Boolean(wrapper) - JPA 매핑:
@Column
isActive: boolean # boolean (기본값: false)
isVerified: Boolean # Boolean (nullable)
Date/Time Types
date
- Java 타입:
LocalDate - JPA 매핑:
@Column - Description: 날짜만 (시간 없음)
birthDate: date # 생년월일
startDate: date # 시작일
datetime
- Java 타입:
LocalDateTime - JPA 매핑:
@Column - Description: 날짜와 시간
createDate: datetime # 생성일시
lastModifiedDate: datetime # 수정일 시
Array Types
int[]
- Java 타입:
int[]또는 커스텀 컨버터 필요 - Description: 정수 배열
coordinates: int[] @env:integerarray # 좌표 배열
scores: int[] @env:integerarray # 점수 배열
string[]
- Java 타입:
String[]또는 커스텀 컨버터 필요 - Description: 문자열 배열
tags: string[] @env:stringarray # 태그 배열
categories: string[] @env:stringarray # 카테고리 배열
경고
배열 타입 사용 시 env.yml에 해당 컨버터 어노테이션을 정의해야 합니다.
config:
annotations:
integerarray: "@entity:Convert(converter = io.elasticore.springboot3.util.IntegerArrayConverter.class)"
stringarray: "@entity:Convert(converter = io.elasticore.springboot3.util.StringArrayConverter.class)"
Collection Types
List<Type>
- Java 타입:
List<Type> - Description: 리스트 타입 (JPA 관계 매핑에 사용)
articles: List<Article> @OneToMany(mappedBy="board")
roles: List<Role> @ManyToMany
tags: List<String>
Reference Types
EntityName (엔티티 참조)
- Java 타입: 해당 엔티티 클래스
- Description: 다른 엔티티 참조 (JPA 관계)
board: Board @ManyToOne # Board 엔티티 참조
author: User @ManyToOne # User 엔티티 참조
EnumName (열거형 참조)
- Java 타입: 해당 Enum 클래스
- Description: Enumeration 타입 참조
boardType: BoardType # BoardType 열거형 참조
status: UserStatus # UserStatus 열거형 참조
Default Search Conditions by Type
| 타입 | 자동 검색 조건 | 설명 |
|---|---|---|
string | @search(like) | 부분 일치 검색 |
datetime | @search(between) | 범위 검색 |
date | @search(between) | 범위 검색 |
Enum | @search(eq) | 정확 일치 검색 |
List<> | @search(in) | 다중 선택 검색 |
int, long | - | 명시적 지정 필요 |
boolean | @search(eq) | 정확 일치 검색 |
NOT NULL Notation
필드 타입 뒤에 !를 붙이면 NOT NULL 제약조건이 적용됩니다.
name: string(100)! # NOT NULL
email: string(255)! # NOT NULL
title: string(200)! # NOT NULL
count: int # nullable (기본)
Comprehensive Example
entity:
Product:
meta: entity @expose(20)
fields:
productId: long @id @sequence
name: string(200)! @search(like)
description: text
price: bigdecimal(10.2) @search(between)
stockCount: int @default(0)
weight: double
isActive: boolean @default(true) @search(eq)
category: CategoryType @search(eq)
tags: string[] @env:stringarray
createDate: datetime @search(between)
manufacturer: Manufacturer @ManyToOne
reviews: List<Review> @OneToMany(mappedBy="product")