Korean Hibernate Integration

Last updated by admin 3 years ago

Hibernate? ????

??? ???? Hibernate? ????

?? GORM (Grails Object Relational Mapping)? ???? ??? ??? ???? ???? ???? ??? ???? ?? Hibernate? ??? ?? ????. "%PROJECT_HOME%hibernate" ???? ?? "hibernate.cfg.xml" ??? ???? ??? ???? ??? ??? ??? ?? hbm ?? ??? ????? ???. ??? ?? ? ??? ??? Hibernate ???? ? ?????.

? ??? ?? ??? ??? ??? ???? Grails? ??? ???? ?????, ?????? ???? ? ???? ??? ? ?? ???.

?? ???? Hibernate ??? ??? ????

??? ??? ??? ?? ?? Hibernate? ???? ??? ?? ??? ??? ??? ???? ?? ????. ??? "hibernate.cfg.xml" ??? hbm ?? ???? "%PROJECT_HOME%hibernate" ????? ????? ?? ???.

? ???? ?? GORM ?? ???? ?? ???? ?? ???? ?? ???? ? ????!

Hibernate ?????(Annotations)?? ????

Grails? ?? Hibernate? Java 5.0 ????? ??? ???? ??? ???? ??? ?? ?????. ??? ?? ??? ??? "configClass"? ???? ???? ????? ??? ?????? ??? ??? ? ????:

import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration
class DevelopmentDataSource {
   def configClass = GrailsAnnotationConfiguration.class
   … // remaining properties
}
??? ??? ?? ?????. ?, ??? Java 5.0? ???? ??????. ?? ?? ???? ??? EJB 3.0 ??? ??? ??? ??????? ????? ?? ???. ??? ??? Hibernate ????? ?? ? ?????:
package com.books;
@Entity
public class Book {
    private Long id;
    private String title;
    private String description;
    private Date date;

@Id @GeneratedValue public Long getId() { return id; }

public void setId(Long id) { this.id = id; }

public String getTitle() { return title; }

public void setTitle(String title) { this.title = title; }

public String getDescription() { return description; }

public void setDescription(String description) { this.description = description; } }

? ??? ???? ???? Hibernate sessionFactory? ???? ???. "%PROJECT_HOME%/hibernate/hibernate.cfg.xml" ??? ?? ???? ???? ???:
<hibernate-configuration>
    <session-factory>
        <mapping package="com.books" />
        <mapping class="com.books.Book" />
    </session-factory>
</hibernate-configuration>
?? ? ????! Grails? ???? ??? ?? ???? ? ???? ???? ??? ????. Hibernate ??? ???? ? ? ?? ?? ???? ?? ???? ???? ? ?????.