很多时候,我会得到这样的堆栈跟踪信息(请参见箭头以了解困惑的行):
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [PRIMARY]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:164)
at org.springframework.orm.hibernate5.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:741)
at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:589)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
---------> at com.panpwr.admin.services.detector.SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639.saveComplexRuleAndActionTemplates(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
...
...
...
$$符号在这行中是什么意思,“生成”是什么意思?
com.panpwr.admin.services.detector.SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639.saveComplexRuleAndActionTemplates(<generated>)
为什么只说执行的方法而不是其中的行?
最佳答案
$
是类名称中允许使用的字符。
名称SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639
暗示它是一个类,由Spring框架使用CGLIB在运行时动态生成。
他们使用$$
和数字偏移量使该类名唯一,以避免与现有类冲突。
stracktrace中的字符串(<generated>)
也由CGLIB生成:
当CGLIB在运行时创建类时,它将<generated>
用作源文件名称的占位符。然后,堆栈跟踪仅打印此字符串,而不是实际的源文件和行号。