You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docbkx/reference/mapping.xml
+39-3Lines changed: 39 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -128,8 +128,6 @@ public class Person {
128
128
</para>
129
129
130
130
<example>
131
-
<title>Child object referred to using a DBRef</title>
132
-
133
131
<programlistinglanguage="java"><![CDATA[
134
132
@Document
135
133
public class Account {
@@ -171,7 +169,45 @@ public class Person {
171
169
<title>Handling Mapping Framework Events</title>
172
170
173
171
<para>Built into the MongoDB mapping framework are several <classname>org.springframework.context.ApplicationEvent</classname>
174
-
events that your application can respond to
172
+
events that your application can respond to by registering special beans in the <code>ApplicationContext</code>.
173
+
</para>
174
+
175
+
<para>To intercept an object before it goes through the conversion process (which turns your domain object
176
+
into a <classname>com.mongodb.DBObject</classname>), you'd register a subclass of <classname>org.springframework.data.document.mongodb.mapping.event.AbstractMappingEventListener</classname>
177
+
that overrides the <code>onBeforeConvert</code> method. When the event is dispatched, your listener will be
178
+
called and passed the domain object before it goes into the converter.
179
+
</para>
180
+
181
+
<example>
182
+
<programlistinglanguage="java"><![CDATA[
183
+
public class BeforeConvertListener<Person> extends AbstractMappingEventListener {
184
+
@Override
185
+
public void onBeforeConvert(Person p) {
186
+
... does some auditing manipulation, set timestamps, whatever ...
187
+
}
188
+
}
189
+
]]></programlisting>
190
+
</example>
191
+
192
+
<para>To intercept an object before it goes into the database, you'd register a subclass of
0 commit comments