Skip to main content

Field Types Reference

Overview

ElastiCORE DSL supports a variety of field types, each of which is automatically mapped to the corresponding Java type and JPA column mapping.

String Types

string(n)

  • Java type: String
  • JPA mapping: @Column(length = n)
  • Description: String with a specified maximum length
  • NOT NULL: Append ! suffix (e.g., string(100)!)
name: string(100)        # VARCHAR(100), nullable
email: string(255)! # VARCHAR(255), NOT NULL

text

  • Java type: String
  • JPA mapping: @Column(columnDefinition = "TEXT") or @Lob
  • Description: Long text (no length limit)
content: text            # TEXT type
description: text # Long description field

Numeric Types

int / Integer

  • Java type: int (primitive) / Integer (wrapper)
  • JPA mapping: @Column
  • Description: 32-bit integer
age: int                 # int (primitive)
count: Integer # Integer (wrapper, nullable)

long / Long

  • Java type: long (primitive) / Long (wrapper)
  • JPA mapping: @Column
  • Description: 64-bit integer
id: long @id @sequence   # Commonly used as primary key
totalCount: Long # Long (wrapper, nullable)

double / Double

  • Java type: double (primitive) / Double (wrapper)
  • JPA mapping: @Column
  • Description: 64-bit floating-point number
price: double            # Price (floating-point)
rating: Double # Rating (nullable)

bigdecimal(precision.scale)

  • Java type: BigDecimal
  • JPA mapping: @Column(precision = p, scale = s)
  • Description: Fixed-point number (recommended for financial data)
amount: bigdecimal(15.2)     # precision=15, scale=2
rate: bigdecimal(10.4) # precision=10, scale=4
salary: bigdecimal(12.2) # Salary (precision 12, scale 2)
tip

Use bigdecimal instead of double for financial data or calculations requiring precision.

Boolean Types

boolean / Boolean

  • Java type: boolean (primitive) / Boolean (wrapper)
  • JPA mapping: @Column
isActive: boolean            # boolean (default: false)
isVerified: Boolean # Boolean (nullable)

Date/Time Types

date

  • Java type: LocalDate
  • JPA mapping: @Column
  • Description: Date only (no time component)
birthDate: date              # Date of birth
startDate: date # Start date

datetime

  • Java type: LocalDateTime
  • JPA mapping: @Column
  • Description: Date and time
createDate: datetime         # Creation timestamp
lastModifiedDate: datetime # Modification timestamp

Array Types

int[]

  • Java type: int[] or requires a custom converter
  • Description: Integer array
coordinates: int[] @env:integerarray    # Coordinate array
scores: int[] @env:integerarray # Score array

string[]

  • Java type: String[] or requires a custom converter
  • Description: String array
tags: string[] @env:stringarray         # Tag array
categories: string[] @env:stringarray # Category array
warning

When using array types, the corresponding converter annotations must be defined in 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 type: List<Type>
  • Description: List type (used for JPA relationship mapping)
articles: List<Article> @OneToMany(mappedBy="board")
roles: List<Role> @ManyToMany
tags: List<String>

Reference Types

EntityName (Entity Reference)

  • Java type: The corresponding entity class
  • Description: Reference to another entity (JPA relationship)
board: Board @ManyToOne          # Reference to Board entity
author: User @ManyToOne # Reference to User entity

EnumName (Enumeration Reference)

  • Java type: The corresponding Enum class
  • Description: Reference to an Enumeration type
boardType: BoardType             # Reference to BoardType enum
status: UserStatus # Reference to UserStatus enum

Default Search Conditions by Type

TypeAuto Search ConditionDescription
string@search(like)Partial match search
datetime@search(between)Range search
date@search(between)Range search
Enum@search(eq)Exact match search
List<>@search(in)Multi-select search
int, long-Must be specified explicitly
boolean@search(eq)Exact match search

NOT NULL Notation

Appending ! after the field type applies a NOT NULL constraint.

name: string(100)!       # NOT NULL
email: string(255)! # NOT NULL
title: string(200)! # NOT NULL
count: int # nullable (default)

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")