43
43
import static org .hibernate .pretty .MessageHelper .infoString ;
44
44
45
45
/**
46
- * A convenience base class for listeners responding to save events.
46
+ * A convenience base class for listeners responding to persist or merge events.
47
+ * <p>
48
+ * This class contains common functionality for persisting new transient instances.
47
49
*
48
50
* @author Steve Ebersole.
49
51
*/
@@ -58,13 +60,13 @@ public void injectCallbackRegistry(CallbackRegistry callbackRegistry) {
58
60
}
59
61
60
62
/**
61
- * Prepares the save call using the given requested id.
63
+ * Prepares the persist call using the given requested id.
62
64
*
63
- * @param entity The entity to be saved.
64
- * @param requestedId The id to which to associate the entity.
65
- * @param entityName The name of the entity being saved.
66
- * @param context Generally cascade-specific information.
67
- * @param source The session which is the source of this save event.
65
+ * @param entity The entity to be persisted
66
+ * @param requestedId The id with which to associate the entity
67
+ * @param entityName The name of the entity being persisted
68
+ * @param context Generally cascade-specific information
69
+ * @param source The session which is the source of this event
68
70
*
69
71
* @return The id used to save the entity.
70
72
*/
@@ -79,18 +81,18 @@ protected Object saveWithRequestedId(
79
81
}
80
82
81
83
/**
82
- * Prepares the save call using a newly generated id.
84
+ * Prepares the persist call using a newly generated id.
83
85
*
84
- * @param entity The entity to be saved
85
- * @param entityName The entity-name for the entity to be saved
86
- * @param context Generally cascade-specific information.
87
- * @param source The session which is the source of this save event.
86
+ * @param entity The entity to be persisted
87
+ * @param entityName The entity-name for the entity to be persisted
88
+ * @param context Generally cascade-specific information
89
+ * @param source The session which is the source of this persist event
88
90
* @param requiresImmediateIdAccess does the event context require
89
91
* access to the identifier immediately after execution of this method
90
92
* (if not, post-insert style id generators may be postponed if we are
91
93
* outside a transaction).
92
94
*
93
- * @return The id used to save the entity; may be null depending on the
95
+ * @return The id used to persist the entity; may be null depending on the
94
96
* type of id generator used and the requiresImmediateIdAccess value
95
97
*/
96
98
protected Object saveWithGeneratedId (
@@ -140,10 +142,10 @@ else if ( generatedBeforeExecution ) {
140
142
* Generate an id before execution of the insert statements,
141
143
* using the given {@link BeforeExecutionGenerator}.
142
144
*
143
- * @param entity The entity instance to be saved
144
- * @param source The session which is the source of this save event.
145
- * @param generator The entity's generator
146
- * @param persister The entity's persister instance.
145
+ * @param entity The entity instance to be persisted
146
+ * @param source The session which is the source of this persist event
147
+ * @param generator The generator for the entity id
148
+ * @param persister The persister for the entity
147
149
*
148
150
* @return The generated id
149
151
*/
@@ -158,7 +160,7 @@ private static Object generateId(
158
160
throw new IdentifierGenerationException ( "Null id generated for entity '" + persister .getEntityName () + "'" );
159
161
}
160
162
else {
161
- if ( LOG .isDebugEnabled () ) {
163
+ if ( LOG .isTraceEnabled () ) {
162
164
// TODO: define toString()s for generators
163
165
LOG .tracef (
164
166
"Generated identifier [%s] using generator '%s'" ,
@@ -171,18 +173,18 @@ private static Object generateId(
171
173
}
172
174
173
175
/**
174
- * Prepares the save call by checking the session caches for a pre-existing
176
+ * Prepares the persist call by checking the session caches for a pre-existing
175
177
* entity and performing any lifecycle callbacks.
176
178
*
177
- * @param entity The entity to be saved.
178
- * @param id The id by which to save the entity.
179
- * @param persister The entity's persister instance.
179
+ * @param entity The entity to be persisted
180
+ * @param id The id by which to persist the entity
181
+ * @param persister The entity's persister instance
180
182
* @param useIdentityColumn Is an identity column being used?
181
- * @param context Generally cascade-specific information.
182
- * @param source The session from which the event originated.
183
+ * @param context Generally cascade-specific information
184
+ * @param source The session from which the event originated
183
185
* @param delayIdentityInserts Should the identity insert be delayed?
184
186
*
185
- * @return The id used to save the entity; may be null depending on the
187
+ * @return The id used to persist the entity; may be null depending on the
186
188
* type of id generator used and on delayIdentityInserts
187
189
*/
188
190
protected Object performSave (
@@ -211,7 +213,7 @@ protected Object performSave(
211
213
}
212
214
213
215
if ( LOG .isTraceEnabled () ) {
214
- LOG .trace ( "Saving " + infoString ( persister , id , source .getFactory () ) );
216
+ LOG .trace ( "Persisting " + infoString ( persister , id , source .getFactory () ) );
215
217
}
216
218
217
219
final EntityKey key = useIdentityColumn ? null : entityKey ( id , persister , source );
@@ -237,18 +239,18 @@ else if ( persistenceContext.containsDeletedUnloadedEntityKey( key ) ) {
237
239
}
238
240
239
241
/**
240
- * Performs all the actual work needed to save an entity (well to get the save moved to
241
- * the execution queue).
242
+ * Performs all the actual work needed to persist an entity
243
+ * (well to get the persist action moved to the execution queue).
242
244
*
243
- * @param entity The entity to be saved
245
+ * @param entity The entity to be persisted
244
246
* @param key The id to be used for saving the entity (or null, in the case of identity columns)
245
- * @param persister The entity's persister instance.
247
+ * @param persister The persister for the entity
246
248
* @param useIdentityColumn Should an identity column be used for id generation?
247
- * @param context Generally cascade-specific information.
248
- * @param source The session which is the source of the current event.
249
+ * @param context Generally cascade-specific information
250
+ * @param source The session which is the source of the current event
249
251
* @param delayIdentityInserts Should the identity insert be delayed?
250
252
*
251
- * @return The id used to save the entity; may be null depending on the
253
+ * @return The id used to persist the entity; may be null depending on the
252
254
* type of id generator used and the requiresImmediateIdAccess value
253
255
*/
254
256
protected Object performSaveOrReplicate (
@@ -394,10 +396,10 @@ protected Map<Object,Object> getMergeMap(C anything) {
394
396
}
395
397
396
398
/**
397
- * After the save , will the version number be incremented
399
+ * After the persist , will the version number be incremented
398
400
* if the instance is modified?
399
401
*
400
- * @return True if the version will be incremented on an entity change after save ;
402
+ * @return True if the version will be incremented on an entity change after persist ;
401
403
* false otherwise.
402
404
*/
403
405
protected boolean isVersionIncrementDisabled () {
@@ -451,11 +453,11 @@ protected boolean substituteValuesIfNecessary(
451
453
}
452
454
453
455
/**
454
- * Handles the calls needed to perform pre-save cascades for the given entity.
456
+ * Handles the calls needed to perform pre-persist cascades for the given entity.
455
457
*
456
- * @param source The session from which the save event originated.
457
- * @param persister The entity's persister instance.
458
- * @param entity The entity to be saved.
458
+ * @param source The session from which the persist event originated
459
+ * @param persister The persister for the entity
460
+ * @param entity The entity to be persisted
459
461
* @param context Generally cascade-specific data
460
462
*/
461
463
protected void cascadeBeforeSave (
@@ -482,11 +484,11 @@ protected void cascadeBeforeSave(
482
484
}
483
485
484
486
/**
485
- * Handles calls needed to perform post-save cascades.
487
+ * Handles calls needed to perform post-persist cascades.
486
488
*
487
- * @param source The session from which the event originated.
488
- * @param persister The entity's persister instance.
489
- * @param entity The entity being saved.
489
+ * @param source The session from which the event originated
490
+ * @param persister The persister for the entity
491
+ * @param entity The entity being persisted
490
492
* @param context Generally cascade-specific data
491
493
*/
492
494
protected void cascadeAfterSave (
0 commit comments