📄 events.po
字号:
#, fuzzymsgid ""msgstr """PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Content-Type: text/plain; charset=utf-8\n"#: index.docbook:5msgid "Interceptors and events"msgstr "Interceptores y eventos"#: index.docbook:7msgid """It is often useful for the application to react to certain events that occur ""inside Hibernate. This allows implementation of certain kinds of generic ""functionality, and extension of Hibernate functionality."msgstr """Frecuentemente es útil para la aplicación reaccionar a ciertos ""eventos que ocurran dentro de Hibernate. Esto permite la implementació""n de ciertos tipos de funcionalidade genérica, y extensión de ""la funcionalidad de Hibernate."#: index.docbook:14msgid "Interceptors"msgstr "Interceptores"#: index.docbook:16msgid """The <literal>Interceptor</literal> interface provides callbacks from the ""session to the application allowing the application to inspect and/or ""manipulate properties of a persistent object before it is saved, updated, ""deleted or loaded. One possible use for this is to track auditing ""information. For example, the following <literal>Interceptor</literal> ""automatically sets the <literal>createTimestamp</literal> when an ""<literal>Auditable</literal> is created and updates the ""<literal>lastUpdateTimestamp</literal> property when an <literal>Auditable</""literal> is updated."msgstr """La interface <literal>Interceptor</literal> provee callbacks desde la ""sesión a la aplicación permitiendo a ésta última ""inspeccionar y/o manipular las propiedades de un objeto persistente antes ""que sea salvado, actualizado, borrado o cargado. Un uso posible de esto es ""seguir la pista de información de auditoría. Por ejemplo, el ""siguiente <literal>Interceptor</literal> establece automáticamente el ""<literal>createTimestamp</literal> cuando un <literal>Auditable</literal> es ""creado y actualiza la propiedad <literal>lastUpdateTimestamp</literal> ""cuando un <literal>Auditable</literal> es acutalizado."#: index.docbook:27msgid """You may either implement <literal>Interceptor</literal> directly or (better) ""extend <literal>EmptyInterceptor</literal>."msgstr """UNTRANSLATED! You may either implement <literal>Interceptor</literal> ""directly or (better) extend <literal>EmptyInterceptor</literal>."#: index.docbook:32msgid """<![CDATA[package org.hibernate.test;\n""\n""import java.io.Serializable;\n""import java.util.Date;\n""import java.util.Iterator;\n""\n""import org.hibernate.EmptyInterceptor;\n""import org.hibernate.Transaction;\n""import org.hibernate.type.Type;\n""\n""public class AuditInterceptor extends EmptyInterceptor {\n""\n"" private int updates;\n"" private int creates;\n"" private int loads;\n""\n"" public void onDelete(Object entity,\n"" Serializable id,\n"" Object[] state,\n"" String[] propertyNames,\n"" Type[] types) {\n"" // do nothing\n"" }\n""\n"" public boolean onFlushDirty(Object entity,\n"" Serializable id,\n"" Object[] currentState,\n"" Object[] previousState,\n"" String[] propertyNames,\n"" Type[] types) {\n""\n"" if ( entity instanceof Auditable ) {\n"" updates++;\n"" for ( int i=0; i < propertyNames.length; i++ ) {\n"" if ( \"lastUpdateTimestamp\".equals( propertyNames[i] ) ) {\n"" currentState[i] = new Date();\n"" return true;\n"" }\n"" }\n"" }\n"" return false;\n"" }\n""\n"" public boolean onLoad(Object entity,\n"" Serializable id,\n"" Object[] state,\n"" String[] propertyNames,\n"" Type[] types) {\n"" if ( entity instanceof Auditable ) {\n"" loads++;\n"" }\n"" return false;\n"" }\n""\n"" public boolean onSave(Object entity,\n"" Serializable id,\n"" Object[] state,\n"" String[] propertyNames,\n"" Type[] types) {\n""\n"" if ( entity instanceof Auditable ) {\n"" creates++;\n"" for ( int i=0; i<propertyNames.length; i++ ) {\n"" if ( \"createTimestamp\".equals( propertyNames[i] ) ) {\n"" state[i] = new Date();\n"" return true;\n"" }\n"" }\n"" }\n"" return false;\n"" }\n""\n"" public void afterTransactionCompletion(Transaction tx) {\n"" if ( tx.wasCommitted() ) {\n"" System.out.println(\"Creations: \" + creates + \", Updates: \" + ""updates, \"Loads: \" + loads);\n"" }\n"" updates=0;\n"" creates=0;\n"" loads=0;\n"" }\n""\n""}]]>"msgstr """<![CDATA[package org.hibernate.test;\n""\n""import java.io.Serializable;\n""import java.util.Date;\n""import java.util.Iterator;\n""\n""import org.hibernate.Interceptor;\n""import org.hibernate.type.Type;\n""\n""public class AuditInterceptor implements Interceptor, Serializable {\n""\n"" private int updates;\n"" private int creates;\n""\n"" public void onDelete(Object entity,\n"" Serializable id,\n"" Object[] state,\n"" String[] propertyNames,\n"" Type[] types) {\n"" // do nothing\n"" }\n""\n"" public boolean onFlushDirty(Object entity,\n"" Serializable id,\n"" Object[] currentState,\n"" Object[] previousState,\n"" String[] propertyNames,\n"" Type[] types) {\n""\n"" if ( entity instanceof Auditable ) {\n"" updates++;\n"" for ( int i=0; i < propertyNames.length; i++ ) {\n"" if ( \"lastUpdateTimestamp\".equals( propertyNames[i] ) ) {\n"" currentState[i] = new Date();\n"" return true;\n"" }\n"" }\n"" }\n"" return false;\n"" }\n""\n"" public boolean onLoad(Object entity,\n"" Serializable id,\n"" Object[] state,\n"" String[] propertyNames,\n"" Type[] types) {\n"" return false;\n"" }\n""\n"" public boolean onSave(Object entity,\n"" Serializable id,\n"" Object[] state,\n"" String[] propertyNames,\n"" Type[] types) {\n""\n"" if ( entity instanceof Auditable ) {\n"" creates++;\n"" for ( int i=0; i<propertyNames.length; i++ ) {\n"" if ( \"createTimestamp\".equals( propertyNames[i] ) ) {\n"" state[i] = new Date();\n"" return true;\n"" }\n"" }\n"" }\n"" return false;\n"" }\n""\n"" public void postFlush(Iterator entities) {\n"" System.out.println(\"Creations: \" + creates + \", Updates: \" + ""updates);\n"" }\n""\n"" public void preFlush(Iterator entities) {\n"" updates=0;\n"" creates=0;\n"" }\n""\n"" ...\n""\n""}]]>"#: index.docbook:34msgid """Interceptors come in two flavors: <literal>Session</literal>-scoped and ""<literal>SessionFactory</literal>-scoped."msgstr """UNTRANSLATED! Interceptors come in two flavors: <literal>Session</literal>-""scoped and <literal>SessionFactory</literal>-scoped."#: index.docbook:39msgid """A <literal>Session</literal>-scoped interceptor is specified when a session ""is opened using one of the overloaded SessionFactory.openSession() methods ""accepting an <literal>Interceptor</literal>."msgstr """UNTRANSLATED! A <literal>Session</literal>-scoped interceptor is specified ""when a session is opened using one of the overloaded SessionFactory.""openSession() methods accepting an <literal>Interceptor</literal>."#: index.docbook:45msgid "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"msgstr """<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"#: index.docbook:47msgid """A <literal>SessionFactory</literal>-scoped interceptor is registered with ""the <literal>Configuration</literal> object prior to building the ""<literal>SessionFactory</literal>. In this case, the supplied interceptor ""will be applied to all sessions opened from that <literal>SessionFactory</""literal>; this is true unless a session is opened explicitly specifying the ""interceptor to use. <literal>SessionFactory</literal>-scoped interceptors ""must be thread safe, taking care to not store session-specific state since ""multiple sessions will use this interceptor (potentially) concurrently."msgstr """UNTRANSLATED! A <literal>SessionFactory</literal>-scoped interceptor is ""registered with the <literal>Configuration</literal> object prior to ""building the <literal>SessionFactory</literal>. In this case, the supplied ""interceptor will be applied to all sessions opened from that ""<literal>SessionFactory</literal>; this is true unless a session is opened ""explicitly specifying the interceptor to use. <literal>SessionFactory</""literal>-scoped interceptors must be thread safe, taking care to not store ""session-specific state since multiple sessions will use this interceptor ""(potentially) concurrently."#: index.docbook:56msgid """<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -