@@ -317,6 +317,47 @@ public void shouldInsertAuthorUsingMapperClass() throws Exception {
317
317
assertEquals (expected .getBio (), actual .getBio ());
318
318
}
319
319
320
+ @ Test
321
+ public void shouldCommitInsertedAuthor () throws Exception {
322
+ try {
323
+ manager .startManagedSession ();
324
+ AuthorMapper mapper = manager .getMapper (AuthorMapper .class );
325
+ Author expected =
new Author (
500 ,
"cbegin" ,
"******" ,
"[email protected] " ,
"Something..." ,
null );
326
+ mapper .insertAuthor (expected );
327
+ manager .commit ();
328
+ Author actual = mapper .selectAuthor (500 );
329
+ assertNotNull (actual );
330
+ } finally {
331
+ manager .close ();
332
+ }
333
+ }
334
+
335
+ @ Test
336
+ public void shouldRollbackInsertedAuthor () throws Exception {
337
+ try {
338
+ manager .startManagedSession ();
339
+ AuthorMapper mapper = manager .getMapper (AuthorMapper .class );
340
+ Author expected =
new Author (
500 ,
"cbegin" ,
"******" ,
"[email protected] " ,
"Something..." ,
null );
341
+ mapper .insertAuthor (expected );
342
+ manager .rollback ();
343
+ Author actual = mapper .selectAuthor (500 );
344
+ assertNull (actual );
345
+ } finally {
346
+ manager .close ();
347
+ }
348
+ }
349
+
350
+ @ Test
351
+ public void shouldImplicitlyRollbackInsertedAuthor () throws Exception {
352
+ manager .startManagedSession ();
353
+ AuthorMapper mapper = manager .getMapper (AuthorMapper .class );
354
+ Author expected =
new Author (
500 ,
"cbegin" ,
"******" ,
"[email protected] " ,
"Something..." ,
null );
355
+ mapper .insertAuthor (expected );
356
+ manager .close ();
357
+ Author actual = mapper .selectAuthor (500 );
358
+ assertNull (actual );
359
+ }
360
+
320
361
@ Test
321
362
public void shouldDeleteAuthorUsingMapperClass () throws Exception {
322
363
AuthorMapper mapper = manager .getMapper (AuthorMapper .class );
0 commit comments