Skip to content

Commit 5ad6027

Browse files
committed
Add AuditingAnnotationDemo.java
1 parent 56ee9fc commit 5ad6027

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

0 commit comments

Comments
 (0)