File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Spring_part_2/src/main/java/spring/oldboy/lesson_12 Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ package spring .oldboy .lesson_12 ;
2+
3+ import org .springframework .context .support .ClassPathXmlApplicationContext ;
4+ import spring .oldboy .entity .Company ;
5+ import spring .oldboy .repository .CrudRepository ;
6+
7+ public class AuditingAnnotationDemo {
8+ public static void main (String [] args ) {
9+
10+ try (var context = new ClassPathXmlApplicationContext ("application.xml" )) {
11+
12+ CrudRepository companyRepository =
13+ context .getBean ("companyRepository" , CrudRepository .class );
14+ System .out .println (companyRepository .findById (1 ));
15+ Company forDel = new Company (2 );
16+ companyRepository .delete (forDel );
17+ /*
18+ Audit method: findById
19+ Open transaction
20+ findById method... from CompanyRepository
21+ Close transaction
22+ Time execution: 300908
23+
24+ Optional[Company[id=1]]
25+
26+ Audit method: delete
27+ Open transaction
28+ delete method...from CompanyRepository
29+ Close transaction
30+ Time execution: 173238
31+ */
32+ }
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments