DevEnjoy

One Step Closer

Grails

Grails domain key 세팅

2015년 1월 19일 by YongPwi Leave a Comment

Gorm(Grails’ object relational mapping)은 Grails에서 구현된 ORM을 이야기 한다.

오픈소스 프로젝트 진행 중에 my-sql과 key mapping에 고생한 내용을 정리한다.

Grails에서 생성한 Domain은 DB에 Table을 생성하지 않아도 application이 올라갈 때

자동으로 DB Table을 생성해준다.

그러나 Grails Domain에서 생성하는 Table의 key는 내부적으로 id라는 컬럼 명으로

생성하여 자체적으로 관리한다.

Domain에 따로 key를 세팅 해야 할 필요가 있을경우는 하단 코드와 같이 설정하면 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class KeywordList {
    Long keywordListId
    String keywordName
    int keywordCount
    char isDeleted = "N"

    static mapping = {
        version false // 저장 data version 사용 유무
        id name : 'keywordListId' // DB에 생성될 primary key(auto increment)
    }

    static constraints = {
        // 컬럼 제약조건 정의
        keywordName(nullable: false)
        keywordCount(nullable: false)
        keywordType(nullable: false)
        isDeleted(nullable: false)
    }
}
Posted in: Database, Grails, Groovy, MySQL, Programing, Talk Tagged: domain, Grails, key, primary key

Calendar

5월 2025
일 월 화 수 목 금 토
« 4월    
 123
45678910
11121314151617
18192021222324
25262728293031

Recent Posts

  • ubuntu bastion 설정
  • Spring Boot properties 암호화
  • Git Repository Bitbucket과 Issue Tracker Redmine 연동 설정
  • Spring Security 동일 session 제어
  • Spring @Mock, @Mockbean, @InjectMock

Recent Comments

  • pzotov (Ubuntu 14.04에서 Sonarqube 6.7.1 service 등록)
  • cours de theatre paris (AWS ELB와 Auto Scaling 연동, nginx)
  • bayern munich (IntelliJ EAP Font rendering)
  • camiseta del chelsea (OS X에서 APP 아이콘 변경)
  • cheap football shirts replica (jQuery Ajax에서 json Array 직렬화)

Copyright © [the-year] [site-link].

Powered by [wp-link] and [theme-link].