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

📄 session_api.pot

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 POT
📖 第 1 页 / 共 3 页
字号:
#: session_api.xml:876(title) msgid "Deleting persistent objects"msgstr ""#: session_api.xml:878(para) msgid "<literal>Session.delete()</literal> will remove an object's state from the database. Of course, your application might still hold a reference to a deleted object. It's best to think of <literal>delete()</literal> as making a persistent instance transient."msgstr ""#: session_api.xml:887(para) msgid "You may delete objects in any order you like, without risk of foreign key constraint violations. It is still possible to violate a <literal>NOT NULL</literal> constraint on a foreign key column by deleting objects in the wrong order, e.g. if you delete the parent, but forget to delete the children."msgstr ""#: session_api.xml:898(title) msgid "Replicating object between two different datastores"msgstr ""#: session_api.xml:900(para) msgid "It is occasionally useful to be able to take a graph of persistent instances and make them persistent in a different datastore, without regenerating identifier values."msgstr ""#: session_api.xml:920(para) msgid "The <literal>ReplicationMode</literal> determines how <literal>replicate()</literal> will deal with conflicts with existing rows in the database."msgstr ""#: session_api.xml:927(para) msgid "<literal>ReplicationMode.IGNORE</literal> - ignore the object when there is an existing database row with the same identifier"msgstr ""#: session_api.xml:933(para) msgid "<literal>ReplicationMode.OVERWRITE</literal> - overwrite any existing database row with the same identifier"msgstr ""#: session_api.xml:939(para) msgid "<literal>ReplicationMode.EXCEPTION</literal> - throw an exception if there is an existing database row with the same identifier"msgstr ""#: session_api.xml:945(para) msgid "<literal>ReplicationMode.LATEST_VERSION</literal> - overwrite the row if its version number is earlier than the version number of the object, or ignore the object otherwise"msgstr ""#: session_api.xml:953(para) msgid "Usecases for this feature include reconciling data entered into different database instances, upgrading system configuration information during product upgrades, rolling back changes made during non-ACID transactions and more."msgstr ""#: session_api.xml:962(title) msgid "Flushing the Session"msgstr ""#: session_api.xml:964(para) msgid "From time to time the <literal>Session</literal> will execute the SQL statements needed to synchronize the JDBC connection's state with the state of objects held in memory. This process, <emphasis>flush</emphasis>, occurs by default at the following points"msgstr ""#: session_api.xml:973(para) msgid "before some query executions"msgstr ""#: session_api.xml:978(para) msgid "from <literal>org.hibernate.Transaction.commit()</literal>"msgstr ""#: session_api.xml:983(para) msgid "from <literal>Session.flush()</literal>"msgstr ""#: session_api.xml:989(para) msgid "The SQL statements are issued in the following order"msgstr ""#: session_api.xml:995(para) msgid "all entity insertions, in the same order the corresponding objects were saved using <literal>Session.save()</literal>"msgstr ""#: session_api.xml:1001(para) msgid "all entity updates"msgstr ""#: session_api.xml:1006(para) msgid "all collection deletions"msgstr ""#: session_api.xml:1011(para) msgid "all collection element deletions, updates and insertions"msgstr ""#: session_api.xml:1016(para) msgid "all collection insertions"msgstr ""#: session_api.xml:1021(para) msgid "all entity deletions, in the same order the corresponding objects were deleted using <literal>Session.delete()</literal>"msgstr ""#: session_api.xml:1028(para) msgid "(An exception is that objects using <literal>native</literal> ID generation are inserted when they are saved.)"msgstr ""#: session_api.xml:1033(para) msgid "Except when you explicity <literal>flush()</literal>, there are absolutely no guarantees about <emphasis>when</emphasis> the <literal>Session</literal> executes the JDBC calls, only the <emphasis>order</emphasis> in which they are executed. However, Hibernate does guarantee that the <literal>Query.list(..)</literal> will never return stale data; nor will they return the wrong data."msgstr ""#: session_api.xml:1041(para) msgid "It is possible to change the default behavior so that flush occurs less frequently. The <literal>FlushMode</literal> class defines three different modes: only flush at commit time (and only when the Hibernate <literal>Transaction</literal> API is used), flush automatically using the explained routine, or never flush unless <literal>flush()</literal> is called explicitly. The last mode is useful for long running units of work, where a <literal>Session</literal> is kept open and disconnected for a long time (see <xref linkend=\"transactions-optimistic-longsession\"/>)."msgstr ""#: session_api.xml:1066(para) msgid "During flush, an exception might occur (e.g. if a DML operation violates a constraint). Since handling exceptions involves some understanding of Hibernate's transactional behavior, we discuss it in <xref linkend=\"transactions\"/>."msgstr ""#: session_api.xml:1075(title) msgid "Transitive persistence"msgstr ""#: session_api.xml:1077(para) msgid "It is quite cumbersome to save, delete, or reattach individual objects, especially if you deal with a graph of associated objects. A common case is a parent/child relationship. Consider the following example:"msgstr ""#: session_api.xml:1083(para) msgid "If the children in a parent/child relationship would be value typed (e.g. a collection of addresses or strings), their life cycle would depend on the parent and no further action would be required for convenient \"cascading\" of state changes. When the parent is saved, the value-typed child objects are saved as well, when the parent is deleted, the children will be deleted, etc. This even works for operations such as the removal of a child from the collection; Hibernate will detect this and, since value-typed objects can't have shared references, delete the child from the database."msgstr ""#: session_api.xml:1094(para) msgid "Now consider the same scenario with parent and child objects being entities, not value-types (e.g. categories and items, or parent and child cats). Entities have their own life cycle, support shared references (so removing an entity from the collection does not mean it can be deleted), and there is by default no cascading of state from one entity to any other associated entities. Hibernate does not implement <emphasis>persistence by reachability</emphasis> by default."msgstr ""#: session_api.xml:1103(para) msgid "For each basic operation of the Hibernate session - including <literal>persist(), merge(), saveOrUpdate(), delete(), lock(), refresh(), evict(), replicate()</literal> - there is a corresponding cascade style. Respectively, the cascade styles are named <literal>create, merge, save-update, delete, lock, refresh, evict, replicate</literal>. If you want an operation to be cascaded along an association, you must indicate that in the mapping document. For example:"msgstr ""#: session_api.xml:1114(para) msgid "Cascade styles my be combined:"msgstr ""#: session_api.xml:1120(para) msgid "You may even use <literal>cascade=\"all\"</literal> to specify that <emphasis>all</emphasis> operations should be cascaded along the association. The default <literal>cascade=\"none\"</literal> specifies that no operations are to be cascaded."msgstr ""#: session_api.xml:1126(para) msgid "A special cascade style, <literal>delete-orphan</literal>, applies only to one-to-many associations, and indicates that the <literal>delete()</literal> operation should be applied to any child object that is removed from the association."msgstr ""#: session_api.xml:1133(para) msgid "Recommendations:"msgstr ""#: session_api.xml:1139(para) msgid "It doesn't usually make sense to enable cascade on a <literal>&lt;many-to-one&gt;</literal> or <literal>&lt;many-to-many&gt;</literal> association. Cascade is often useful for <literal>&lt;one-to-one&gt;</literal> and <literal>&lt;one-to-many&gt;</literal> associations."msgstr ""#: session_api.xml:1147(para) msgid "If the child object's lifespan is bounded by the lifespan of the parent object, make it a <emphasis>life cycle object</emphasis> by specifying <literal>cascade=\"all,delete-orphan\"</literal>."msgstr ""#: session_api.xml:1154(para) msgid "Otherwise, you might not need cascade at all. But if you think that you will often be working with the parent and children together in the same transaction, and you want to save yourself some typing, consider using <literal>cascade=\"persist,merge,save-update\"</literal>."msgstr ""#: session_api.xml:1162(para) msgid "Mapping an association (either a single valued association, or a collection) with <literal>cascade=\"all\"</literal> marks the association as a <emphasis>parent/child</emphasis> style relationship where save/update/delete of the parent results in save/update/delete of the child or children."msgstr ""#: session_api.xml:1168(para) msgid "Futhermore, a mere reference to a child from a persistent parent will result in save/update of the child. This metaphor is incomplete, however. A child which becomes unreferenced by its parent is <emphasis>not</emphasis> automatically deleted, except in the case of a <literal>&lt;one-to-many&gt;</literal> association mapped with <literal>cascade=\"delete-orphan\"</literal>. The precise semantics of cascading operations for a parent/child relationship are as follows:"msgstr ""#: session_api.xml:1179(para) msgid "If a parent is passed to <literal>persist()</literal>, all children are passed to <literal>persist()</literal>"msgstr ""#: session_api.xml:1185(para) msgid "If a parent is passed to <literal>merge()</literal>, all children are passed to <literal>merge()</literal>"msgstr ""#: session_api.xml:1191(para) msgid "If a parent is passed to <literal>save()</literal>, <literal>update()</literal> or <literal>saveOrUpdate()</literal>, all children are passed to <literal>saveOrUpdate()</literal>"msgstr ""#: session_api.xml:1197(para) msgid "If a transient or detached child becomes referenced by a persistent parent, it is passed to <literal>saveOrUpdate()</literal>"msgstr ""#: session_api.xml:1203(para) msgid "If a parent is deleted, all children are passed to <literal>delete()</literal>"msgstr ""#: session_api.xml:1208(para) msgid "If a child is dereferenced by a persistent parent, <emphasis>nothing special happens</emphasis> - the application should explicitly delete the child if necessary - unless <literal>cascade=\"delete-orphan\"</literal>, in which case the \"orphaned\" child is deleted."msgstr ""#: session_api.xml:1217(para) msgid "Finally, note that cascading of operations can be applied to an object graph at <emphasis>call time</emphasis> or at <emphasis>flush time</emphasis>. All operations, if enabled, are cascaded to associated entities reachable when the operation is executed. However, <literal>save-upate</literal> and <literal>delete-orphan</literal> are transitive for all associated entities reachable during flush of the <literal>Session</literal>."msgstr ""#: session_api.xml:1229(title) msgid "Using metadata"msgstr ""#: session_api.xml:1231(para) msgid "Hibernate requires a very rich meta-level model of all entity and value types. From time to time, this model is very useful to the application itself. For example, the application might use Hibernate's metadata to implement a \"smart\" deep-copy algorithm that understands which objects should be copied (eg. mutable value types) and which should not (eg. immutable value types and, possibly, associated entities)."msgstr ""#: session_api.xml:1238(para) msgid "Hibernate exposes metadata via the <literal>ClassMetadata</literal> and <literal>CollectionMetadata</literal> interfaces and the <literal>Type</literal> hierarchy. Instances of the metadata interfaces may be obtained from the <literal>SessionFactory</literal>."msgstr ""#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.#: session_api.xml:0(None) msgid "translator-credits"msgstr ""

⌨️ 快捷键说明

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