📄 tutorial.po
字号:
#. Tag: title#: tutorial.xml:117#, no-c-formatmsgid "The mapping file"msgstr "The mapping file"#. Tag: para#: tutorial.xml:119#, no-c-formatmsgid """Hibernate needs to know how to load and store objects of the persistent ""class. This is where the Hibernate mapping file comes into play. The mapping ""file tells Hibernate what table in the database it has to access, and what ""columns in that table it should use."msgstr """Hibernate는 영속 크래스들에 대한 객체들을 로드시키고 저장시키는 방법을 알 필""요가 있다. 이곳은 Hibernate 매핑 파일이 역할을 행하는 곳이다. 매핑 파일은 ""Hibernate가 접근해야 하는 데이터베이스 내의 테이블이 무엇인지, 그리고 그것이 ""사용해야 하는 그 테이블 내의 컬럼들이 무엇인지를 Hibernate에게 알려준다."#. Tag: para#: tutorial.xml:126#, no-c-formatmsgid "The basic structure of a mapping file looks like this:"msgstr "매핑 파일의 기본 구조는 다음과 같다:"#. Tag: programlisting#: tutorial.xml:130#, no-c-formatmsgid """<![CDATA[<?xml version=\"1.0\"?>\n""<!DOCTYPE hibernate-mapping PUBLIC\n"" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n""\n""<hibernate-mapping>\n""[...]\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:132#, no-c-formatmsgid """Note that the Hibernate DTD is very sophisticated. You can use it for auto-""completion of XML mapping elements and attributes in your editor or IDE. You ""also should open up the DTD file in your text editor - it's the easiest way ""to get an overview of all elements and attributes and to see the defaults, ""as well as some comments. Note that Hibernate will not load the DTD file ""from the web, but first look it up from the classpath of the application. ""The DTD file is included in <literal>hibernate3.jar</literal> as well as in ""the <literal>src/</literal> directory of the Hibernate distribution."msgstr """Hibernate DTD는 매우 정교하다. 당신은 당신의 편집기 또는 IDE 내에서 XML 매핑 ""요소들과 속성들에 대한 자동 완성 기능을 위해 그것을 사용할 수 있다. 당신은 또""한 당신의 텍스트 편집기 내에 DTD 파일을 열 수 있을 것이다 - 그것은 모든 요소""들과 속성들에 대한 전체상을 얻고 디폴트들 뿐만 아니라 몇몇 주석들을 보는 가""장 손쉬운 방법이다. Hibernate는 웹으로부터 DTD 파일을 로드시키지 않지만, 먼""저 어플리케이션의 classpath 경로로부터 그것을 먼저 룩업할 것임을 노트하라. ""DTD 파일은 <literal>hibernate3.jar</literal> 속에 포함되어 있을 뿐만 아니라 ""Hibernate 배포본의 <literal>src/</literal> 디렉토리 속에 포함되어 있다."#. Tag: para#: tutorial.xml:143#, no-c-formatmsgid """We will omit the DTD declaration in future examples to shorten the code. It ""is of course not optional."msgstr """우리는 코드를 간략화 시키기 위해 장래의 예제에서 DTD 선언을 생략할 것이다. 그""것은 물론 옵션이 아니다."#. Tag: para#: tutorial.xml:148#, no-c-formatmsgid """Between the two <literal>hibernate-mapping</literal> tags, include a ""<literal>class</literal> element. All persistent entity classes (again, ""there might be dependent classes later on, which are not first-class ""entities) need such a mapping, to a table in the SQL database:"msgstr """두 개의 <literal>hibernate-mapping</literal> 태그들 사이에 <literal>class</""literal> 요소를 포함시켜라. 모든 영속 엔티티 클래스들(다시금 종속 클래스들일 ""수 있고, 그것은 첫번째-급의 엔티티들이 아니다)은 SQL 데이터베이스 내의 테이블""에 대한 그런 매핑을 필요로 한다:"#. Tag: programlisting#: tutorial.xml:155#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"events.Event\" table=\"EVENTS\">\n""\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:157#, no-c-formatmsgid """So far we told Hibernate how to persist and load object of class ""<literal>Event</literal> to the table <literal>EVENTS</literal>, each ""instance represented by a row in that table. Now we continue with a mapping ""of the unique identifier property to the tables primary key. In addition, as ""we don't want to care about handling this identifier, we configure ""Hibernate's identifier generation strategy for a surrogate primary key ""column:"msgstr """지금까지 우리는 그 테이블 내에 있는 한 행에 의해 표현된 각각의 인스턴스인, 클""래스의 객체를 영속화 시키고 로드시키는 방법을 Hibernate에게 알려주었다. 이제 ""우린느 테이블 프라이머리 키에 대한 유일 식별자 프로퍼티 매핑을 계속 행한다. ""게다가 우리는 이 식별자를 처리하는 것에 주의를 기울이고자 원하지 않으므로, 우""리는 대용 키 프라이머리 키 컬럼에 대한 Hibernate의 식별자 생성 방도를 구성한""다:"#. Tag: programlisting#: tutorial.xml:165#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"events.Event\" table=\"EVENTS\">\n"" <id name=\"id\" column=\"EVENT_ID\">\n"" <generator class=\"native\"/>\n"" </id>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:167#, no-c-formatmsgid """The <literal>id</literal> element is the declaration of the identifer ""property, <literal>name=\"id\"</literal> declares the name of the Java ""property - Hibernate will use the getter and setter methods to access the ""property. The column attribute tells Hibernate which column of the ""<literal>EVENTS</literal> table we use for this primary key. The nested ""<literal>generator</literal> element specifies the identifier generation ""strategy, in this case we used <literal>native</literal>, which picks the ""best strategy depending on the configured database (dialect). Hibernate ""supports database generated, globally unique, as well as application ""assigned identifiers (or any strategy you have written an extension for)."msgstr """<literal>id</literal> 요소는 식별자 프로퍼티의 선언이고, <literal>name=\"id""\"</literal>는 Java 프로퍼티의 이름을 선언한다 - Hibernate는 그 프로퍼티에 접""근하는데 getter 및 setter 메소드들을 사용할 것이다. column 속성은 우리가 ""<literal>EVENTS</literal> 테이블의 어느 컬럼을 이 프라이머리 키로 사용하는지""를 Hibernate에게 알려준다. 내포된 <literal>generator</literal> 요소는 식별자 ""생성 방도를 지정하며, 이 경우에 우리는 <literal>increment</literal>를 사용했""고, 그것은 대개 테스팅(과 튜토리얼들)에 유용한 매우 간단한 메모리-내 숫자 증""가 방법이다. Hibernate는 또한 전역적으로 유일한 데이터베이스에 의해 생성된 식""별자 뿐만 아니라 어플리케이션에 의해 할당된 식별자(또는 당신이 확장으로 작성""한 어떤 방도)를 지원한다."#. Tag: para#: tutorial.xml:180#, no-c-formatmsgid """Finally we include declarations for the persistent properties of the class ""in the mapping file. By default, no properties of the class are considered ""persistent:"msgstr """마지막으로 우리는 매핑 파일 속에서 클래스의 영속 프로퍼티들에 대한 선언들을 ""포함한다. 디폴트로, 클래스의 프로퍼티들은 영속적인 것으로 간주되지 않는다:"#. Tag: programlisting#: tutorial.xml:186#, no-c-formatmsgid """<![CDATA[\n""<hibernate-mapping>\n""\n"" <class name=\"events.Event\" table=\"EVENTS\">\n"" <id name=\"id\" column=\"EVENT_ID\">\n"" <generator class=\"native\"/>\n"" </id>\n"" <property name=\"date\" type=\"timestamp\" column=\"EVENT_DATE\"/>\n"" <property name=\"title\"/>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:188#, no-c-formatmsgid """Just as with the <literal>id</literal> element, the <literal>name</literal> ""attribute of the <literal>property</literal> element tells Hibernate which ""getter and setter methods to use. So, in this case, Hibernate will look for ""<literal>getDate()/setDate()</literal>, as well as <literal>getTitle()/""setTitle()</literal>."msgstr """<literal>id</literal> 요소의 경우처럼, <literal>property</literal> 요소의 ""<literal>name</literal> 속성은 사용할 getter 및 setter 메소드들이 어느 것인지""를 Hibernate에게 알려준다. 따라서 이 경우에 Hibernate는 <literal>getDate()/""setDate()</literal> 뿐만 아니라 <literal>getTitle()/setTitle()</literal>을 찾""게 될 것이다."#. Tag: para#: tutorial.xml:195#, no-c-formatmsgid """Why does the <literal>date</literal> property mapping include the ""<literal>column</literal> attribute, but the <literal>title</literal> ""doesn't? Without the <literal>column</literal> attribute Hibernate by ""default uses the property name as the column name. This works fine for ""<literal>title</literal>. However, <literal>date</literal> is a reserved ""keyword in most database, so we better map it to a different name."msgstr """<literal>date</literal> 프로퍼티 매핑은 <literal>column</literal> 속성을 포함""하는데, 왜 <literal>title</literal>은 <literal>column</literal> 속성을 포함하""지 않는가? <literal>column</literal> 속성이 없을 경우 Hibernate는 디폴트로 컬""럼 이름으로서 프로퍼티 이름을 사용한다. 이것은 에 대해 잘 동작한다. 하지만 ""<literal>date</literal>는 대부분의 데이터베이스에서 예약된 키워드이어서, 우리""는 그것을 다른 이름으로 더 좋게 매핑 시킨다."#. Tag: para#: tutorial.xml:204#, no-c-formatmsgid """The next interesting thing is that the <literal>title</literal> mapping also ""lacks a <literal>type</literal> attribute. The types we declare and use in ""the mapping files are not, as you might expect, Java data types. They are ""also not SQL database types. These types are so called <emphasis>Hibernate ""mapping types</emphasis>, converters which can translate from Java to SQL ""data types and vice versa. Again, Hibernate will try to determine the ""correct conversion and mapping type itself if the <literal>type</literal> ""attribute is not present in the mapping. In some cases this automatic ""detection (using Reflection on the Java class) might not have the default ""you expect or need. This is the case with the <literal>date</literal> ""property. Hibernate can't know if the property (which is of <literal>java.""util.Date</literal>) should map to a SQL <literal>date</literal>, ""<literal>timestamp</literal>, or <literal>time</literal> column. We preserve ""full date and time information by mapping the property with a ""<literal>timestamp</literal> converter."msgstr """다음 흥미로운 점은 <literal>title</literal> 매핑 또한 <literal>type</""literal> 속성을 갖지 않는다. 우리가 매핑파일들 속에서 선언하고 사용하는 타입""들은 당신이 예상하는 Java 데이터 타입들이 아니다. 그것들은 또한 SQL 데이터베""이스 타입들도 아니다. 이들 타입들은 이른바 <emphasis>Hibernate 매핑 타입들</""emphasis>, 즉 Java 타입들로부터 SQL 타입들로 변환될 수 있고 반대로 SQL 타입들""로부터 Java 타입들로 매핑될 수 있는 컨버터들이다. 다시말해, <literal>type</""literal> 속성이 매핑 속에 존재하지 않을 경우 Hibernate는 정확환 변환 및 매핑 ""타입 그 자체를 결정하려고 시도할 것이다. 몇몇 경우들에서 (Java 클래스에 대한 ""Reflection을 사용하는) 이 자동적인 검출은 당신이 예상하거나 필요로 하는 디폴""트를 갖지 않을 수도 있다. 이것은 <literal>date</literal> 프로퍼티를 가진 경우""이다. Hibernate는 그 프로퍼티가 SQL <literal>date</literal> 컬럼, ""<literal>timestamp</literal> 컬럼 또는 <literal>time</literal> 컬럼 중 어느 ""것으로 매핑되어야 하는지를 알 수가 없다. 우리는 <literal>timestamp</literal> ""컨버터를 가진 프로퍼티를 매핑함으로써 전체 날짜와 시간 정보를 보존하고 싶다""고 선언한다."#. Tag: para#: tutorial.xml:220#, no-c-formatmsgid """This mapping file should be saved as <literal>Event.hbm.xml</literal>, right ""in the directory next to the <literal>Event</literal> Java class source ""file. The naming of mapping files can be arbitrary, however the <literal>hbm.""xml</literal> suffix is a convention in the Hibernate developer community. ""The directory structure should now look like this:"msgstr """다음 매핑 파일은 <literal>Event</literal> Java 클래스 소스 파일과 같은 디렉토""리 속에 <literal>Event.hbm.xml</literal>로서 저장될 것이다. 매핑 파일들에 대""한 네이밍은 임의적일 수 있지만, 접미사 <literal>hbm.xml</literal>은 ""Hibernate 개발자 공동체 내에서 컨벤션이 되었다. 디렉토리 구조는 이제 다음과 ""같을 것이다:"#. Tag: programlisting#: tutorial.xml:228#, no-c-formatmsgid """<![CDATA[.\n""+lib\n"" <Hibernate and third-party libraries>\n""+src\n"" +events\n"" Event.java\n"" Event.hbm.xml]]>"msgstr ""#. Tag: para#: tutorial.xml:230#, no-c-formatmsgid "We continue with the main configuration of Hibernate."msgstr "우리는 Hibernate의 메인 구성을 계속 행한다."#. Tag: title#: tutorial.xml:237#, no-c-formatmsgid "Hibernate configuration"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -