⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example_parentchild.po

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 PO
📖 第 1 页 / 共 2 页
字号:
msgid "And now, only one SQL <literal>INSERT</literal> would be issued!"msgstr """그리고 이제, 유일하게 한 개의 SQL <literal>INSERT</literal>가 실행될 것이다!"#. Tag: para#: example_parentchild.xml:136#, no-c-formatmsgid """To tighten things up a bit, we could create an <literal>addChild()</literal> ""method of <literal>Parent</literal>."msgstr """약간 거칠게, 우리는 <literal>Parent</literal>의 <literal>addChild()</""literal> 메소드를 생성시킬 수 있다."#. Tag: programlisting#: example_parentchild.xml:141#, no-c-formatmsgid """<![CDATA[public void addChild(Child c) {\n""    c.setParent(this);\n""    children.add(c);\n""}]]>"msgstr ""#. Tag: para#: example_parentchild.xml:143#, no-c-formatmsgid "Now, the code to add a <literal>Child</literal> looks like"msgstr "이제, <literal>Child</literal>를 추가하는 코드는 다음과 같다"#. Tag: programlisting#: example_parentchild.xml:147#, no-c-formatmsgid """<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n""Child c = new Child();\n""p.addChild(c);\n""session.save(c);\n""session.flush();]]>"msgstr ""#. Tag: title#: example_parentchild.xml:152#, no-c-formatmsgid "Cascading life cycle"msgstr "케스케이딩 생명주기"#. Tag: para#: example_parentchild.xml:154#, no-c-formatmsgid """The explicit call to <literal>save()</literal> is still annoying. We will ""address this by using cascades."msgstr """<literal>save()</literal>에 대한 명시적인 호출은 여전히 성가시다. 우리는 케스""케이딩을 사용하여 이것을 얘기할 것이다."#. Tag: programlisting#: example_parentchild.xml:159#, no-c-formatmsgid """<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all\">\n""    <key column=\"parent_id\"/>\n""    <one-to-many class=\"Child\"/>\n""</set>]]>"msgstr ""#. Tag: para#: example_parentchild.xml:161#, no-c-formatmsgid "This simplifies the code above to"msgstr "다음은 위의 코드를 단순화 시킨다"#. Tag: programlisting#: example_parentchild.xml:165#, no-c-formatmsgid """<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n""Child c = new Child();\n""p.addChild(c);\n""session.flush();]]>"msgstr ""#. Tag: para#: example_parentchild.xml:167#, no-c-formatmsgid """Similarly, we don't need to iterate over the children when saving or ""deleting a <literal>Parent</literal>. The following removes <literal>p</""literal> and all its children from the database."msgstr """유사하게, 우리는 <literal>Parent</literal>를 저장하거나 삭제할 때 자식들에 대""해 반복하는 것을 필요로 하지 않는다. 다음은 데이터베이스로부터 <literal>p</""literal>와 모든 그것의 자식들을 제거시킨다."#. Tag: programlisting#: example_parentchild.xml:172#, no-c-formatmsgid """<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n""session.delete(p);\n""session.flush();]]>"msgstr ""#. Tag: para#: example_parentchild.xml:174#, no-c-formatmsgid "However, this code"msgstr "하지만, 다음 코드"#. Tag: programlisting#: example_parentchild.xml:178#, no-c-formatmsgid """<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n""Child c = (Child) p.getChildren().iterator().next();\n""p.getChildren().remove(c);\n""c.setParent(null);\n""session.flush();]]>"msgstr ""#. Tag: para#: example_parentchild.xml:180#, no-c-formatmsgid """will not remove <literal>c</literal> from the database; it will ony remove ""the link to <literal>p</literal> (and cause a <literal>NOT NULL</literal> ""constraint violation, in this case). You need to explicitly <literal>delete()""</literal> the <literal>Child</literal>."msgstr """는 데이터베이스로부터 <literal>c</literal>를 제거하지 않을 것이다; 그것은 오""직 <literal>p</literal>에 대한 링크만을 제거할 것이다(그리고 이 경우에 ""<literal>NOT NULL</literal> 컨스트레인트 위반을 일으킬 것이다 ). 당신은 명시""적으로 <literal>Child</literal>를 <literal>delete()</literal> 시킬 필요가 있""다."#. Tag: programlisting#: example_parentchild.xml:186#, no-c-formatmsgid """<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n""Child c = (Child) p.getChildren().iterator().next();\n""p.getChildren().remove(c);\n""session.delete(c);\n""session.flush();]]>"msgstr ""#. Tag: para#: example_parentchild.xml:188#, no-c-formatmsgid """Now, in our case, a <literal>Child</literal> can't really exist without its ""parent. So if we remove a <literal>Child</literal> from the collection, we ""really do want it to be deleted. For this, we must use <literal>cascade=""\"all-delete-orphan\"</literal>."msgstr """이제 우리의 경우에 <literal>Child</literal>는 그것의 부모 없이는 진정으로 존""재할 수 없다. 따라서 만일 우리가 콜렉션으로부터 하나의 <literal>Child</""literal>를 제거할 경우, 우리는 그것이 정말로 삭제되기를 원한다. 이를 위해 우""리는 <literal>cascade=\"all-delete-orphan\"</literal>을 사용해야 한다."#. Tag: programlisting#: example_parentchild.xml:194#, no-c-formatmsgid """<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all-delete-orphan""\">\n""    <key column=\"parent_id\"/>\n""    <one-to-many class=\"Child\"/>\n""</set>]]>"msgstr ""#. Tag: para#: example_parentchild.xml:196#, no-c-formatmsgid """Note: even though the collection mapping specifies <literal>inverse=\"true""\"</literal>, cascades are still processed by iterating the collection ""elements. So if you require that an object be saved, deleted or updated by ""cascade, you must add it to the collection. It is not enough to simply call ""<literal>setParent()</literal>."msgstr """노트: 비록 콜렉션 매핑이 <literal>inverse=\"true\"</literal>를 지정할 지라""도, 케스케이드들은 여전히 콜렉션 요소들을 반복함으로써 처리된다. 따라서 객체""가 케스케이드에 의해 저장되고, 삭제되거나 업데이트 되는 것을 당신이 필요로 ""할 경우, 당신은 그것을 그 콜렉션에 추가해야 한다. 단순히 <literal>setParent()""</literal>를 호출하는 것으로는 충분하지 않다."#. Tag: title#: example_parentchild.xml:206#, no-c-formatmsgid "Cascades and <literal>unsaved-value</literal>"msgstr "케스케이드들과 <literal>unsaved-value</literal>"#. Tag: para#: example_parentchild.xml:208#, no-c-formatmsgid """Suppose we loaded up a <literal>Parent</literal> in one <literal>Session</""literal>, made some changes in a UI action and wish to persist these changes ""in a new session by calling <literal>update()</literal>. The ""<literal>Parent</literal> will contain a collection of childen and, since ""cascading update is enabled, Hibernate needs to know which children are ""newly instantiated and which represent existing rows in the database. Lets ""assume that both <literal>Parent</literal> and <literal>Child</literal> have ""genenerated identifier properties of type <literal>Long</literal>. Hibernate ""will use the identifier and version/timestamp property value to determine ""which of the children are new. (See <xref linkend=\"objectstate-saveorupdate""\"/>.) <emphasis>In Hibernate3, it is no longer necessary to specify an ""<literal>unsaved-value</literal> explicitly.</emphasis>"msgstr """우리가 하나의 <literal>Session</literal> 속에 <literal>Parent</literal>를 로""드시켰고 UI 액션에서 어떤 변경들을 행했고, <literal>update()</literal>를 호출""하여 새로운 세션에서 이들 변경들을 영속화 시키는 것을 원한다고 가정하자. ""<literal>Parent</literal>는 자식들을 가진 콜렉션을 포함할 것이고, 케스케이딩 ""업데이트가 사용 가능하기 때문에, Hibernate는 어느 자식들이 새로이 초기화 되는""지 그리고 어느 것이 데이터베이스에서 현재 행들을 표현하는지를 알 필요가 있""다. <literal>Parent</literal>와 <literal>Child</literal> 모두 <literal>Long</""literal> 타입의 식별자 프로퍼티들을 생성시켰다고 가정하자. Hibernate는 어느 ""자식들이 새로운 것인지를 결정하는데 식별자와 version/timestamp 프로퍼티 값을 ""사용할 것이다.(<xref linkend=\"objectstate-saveorupdate\"/>을 보라.) ""<emphasis>Hibernate3에서는<literal>unsaved-value</literal>를 더이상 명시적으""로 지정할 필요가 없다.</emphasis>"#. Tag: para#: example_parentchild.xml:220#, no-c-formatmsgid """The following code will update <literal>parent</literal> and <literal>child</""literal> and insert <literal>newChild</literal>."msgstr """다음 코드는 <literal>parent</literal>와 <literal>child</literal>를 업데이트하""고 <literal>newChild</literal>를 삽입시킬 것이다."#. Tag: programlisting#: example_parentchild.xml:225#, no-c-formatmsgid """<![CDATA[//parent and child were both loaded in a previous session\n""parent.addChild(child);\n""Child newChild = new Child();\n""parent.addChild(newChild);\n""session.update(parent);\n""session.flush();]]>"msgstr ""#. Tag: para#: example_parentchild.xml:227#, no-c-formatmsgid """Well, that's all very well for the case of a generated identifier, but what ""about assigned identifiers and composite identifiers? This is more ""difficult, since Hibernate can't use the identifier property to distinguish ""between a newly instantiated object (with an identifier assigned by the ""user) and an object loaded in a previous session. In this case, Hibernate ""will either use the timestamp or version property, or will actually query ""the second-level cache or, worst case, the database, to see if the row ""exists."msgstr """물론 그것은 생성되는 식별자의 경우에는 모두 매우 좋지만, 할당되는 식별자들과 ""composite 식별자들에 대해서는 어떠한가? 이것은 보다 어렵다. 왜냐하면 ""Hibernate는 (사용자에 의해 할당된 식별자를 가진) 새로이 초기화 된 객체와 이""전 세션에서 로드되었던 객체 사이를 구별짓는데 식별자 프로퍼티를 사용할 수 없""기 때문이다. 이 경우에, Hibernate는 timestamp 프로퍼티 또는 version 프로퍼티""를 사용하거나 실제로 second-level 캐시를 질의하거나 가장 나쁜 경우에는 행이 ""존재하는지를 알기 위해 데이터베이스를 질의할 것이다."#. Tag: title#: example_parentchild.xml:260#, no-c-formatmsgid "Conclusion"msgstr "결론"#. Tag: para#: example_parentchild.xml:262#, no-c-formatmsgid """There is quite a bit to digest here and it might look confusing first time ""around. However, in practice, it all works out very nicely. Most Hibernate ""applications use the parent / child pattern in many places."msgstr """여기에 숙지할 것이 약간 있고 그것은 처음에는 혼동스러운 것처럼 보일 수 있다. ""하지만 실제로 그것은 모두 매우 좋게 동작한다. 대부분의 Hibernate 어플리케이션""들은 많은 장소들에서 부모/자식 패턴을 사용한다."#. Tag: para#: example_parentchild.xml:267#, no-c-formatmsgid """We mentioned an alternative in the first paragraph. None of the above issues ""exist in the case of <literal>&lt;composite-element&gt;</literal> mappings, ""which have exactly the semantics of a parent / child relationship. ""Unfortunately, there are two big limitations to composite element classes: ""composite elements may not own collections, and they should not be the child ""of any entity other than the unique parent."msgstr """우리는 첫 번째 단락에서 대안을 언급했다. 위의 쟁점들 중 어느 것도 정확하게 부""모/자식 관계의 의미를 가진, <literal>&lt;composite-element&gt;</literal> 매핑""들의 경우에는 존재하지 않는다. 불행히도, composite 요소 클래스들에 대한 두 개""의 커다란 제약들이 존재한다: composite 요소들은 콜렉션들을 소유하지 않고, 그""것들은 유일한 부모가 아닌 다른 어떤 엔티티의 자식일 수는 없다."

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -