Results 1 to 2 of 2

Thread: hibernate interceptor and AOP

  1. #1
    Join Date
    Feb 2010
    Posts
    12

    Default hibernate interceptor and AOP

    I have a hibernate interceptor for auditing purposes which extends emptyInterceptor and logs info when the entities state changes. I want to selectively apply this interceptor to certain service methods or services in a particular package, so I am trying to do this by either of these 2 methods below, but none seem to work and I am not getting any message that is helpful to identify the problem, the execution just stops while trying to start up


    1)
    <bean id="autoProxyCreator"
    class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator" >
    <property name="beanNames">
    <value>*Service</value>
    </property>
    <property name="interceptorNames">
    <value>entityInterceptor</value>
    </property>
    </bean>

    or

    2)
    <aop:config>
    <aopointcut id="auditIntercept" expression="execution(* com.cerner.edi.dep.service.*.*(..))"/>
    <aop:advisor pointcut-ref="auditIntercept" advice-ref="entityInterceptor" />
    </aop:config>


    any help is appreciated.


    this is the message in the console I get,



    18 10:27:53,330 INFO [AbstractApplicationContext.java:426] : Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext@281d4b]: org.springframework.beans.factory.support.DefaultL istableBeanFactory@5976c2
    2010-02-18 10:27:53,424 INFO [DefaultListableBeanFactory.java:414] : Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@5976c2: defining beans [org.springframework.context.annotation.internalPer sistenceAnnotationProcessor,org.springframework.co ntext.annotation.internalCommonAnnotationProcessor ,org.springframework.context.annotation.internalAu towiredAnnotationProcessor,org.springframework.con text.annotation.internalRequiredAnnotationProcesso r,entityInterceptor,auditDao,subscriberDaoHbn,txDa o,txTypeDao,txService,oracle_dataSource,oracle_sch emaName,sessionFactory,transactionManager,org.spri ngframework.aop.config.internalAutoProxyCreator,au ditIntercept,org.springframework.aop.support.Defau ltBeanFactoryPointcutAdvisor#0]; root of factory hierarchy
    2010-02-18 10:27:53,658 INFO [Version.java:15] : Hibernate Annotations 3.4.0.GA
    2010-02-18 10:27:53,659 INFO [Environment.java:560] : Hibernate 3.3.2.GA
    2010-02-18 10:27:53,659 INFO [Environment.java:593] : hibernate.properties not found
    2010-02-18 10:27:53,659 INFO [Environment.java:771] : Bytecode provider name : javassist
    2010-02-18 10:27:53,659 INFO [Environment.java:652] : using JDK 1.4 java.sql.Timestamp handling
    2010-02-18 10:27:53,721 INFO [Version.java:14] : Hibernate Commons Annotations 3.1.0.GA
    2010-02-18 10:27:53,784 INFO [AnnotationBinder.java:419] : Binding entity from annotated class: com.cerner.edi.dep.entity.EntityAuditRecord
    2010-02-18 10:27:53,815 INFO [EntityBinder.java:422] : Bind entity com.cerner.edi.dep.entity.EntityAuditRecord on table AUDIT_EVENT
    2010-02-18 10:27:53,846 INFO [AnnotationBinder.java:419] : Binding entity from annotated class: com.cerner.edi.dep.entity.Subscriber
    2010-02-18 10:27:53,846 INFO [EntityBinder.java:422] : Bind entity com.cerner.edi.dep.entity.Subscriber on table SUBSCRIBER
    2010-02-18 10:27:53,846 INFO [AnnotationBinder.java:419] : Binding entity from annotated class: com.cerner.edi.dep.entity.Tx
    2010-02-18 10:27:53,846 INFO [EntityBinder.java:422] : Bind entity com.cerner.edi.dep.entity.Tx on table TX
    2010-02-18 10:27:53,877 INFO [AnnotationBinder.java:419] : Binding entity from annotated class: com.cerner.edi.dep.entity.TxAction
    2010-02-18 10:27:53,877 INFO [EntityBinder.java:422] : Bind entity com.cerner.edi.dep.entity.TxAction on table TX_ACTION
    2010-02-18 10:27:53,877 INFO [AnnotationBinder.java:419] : Binding entity from annotated class: com.cerner.edi.dep.entity.TxDetail
    2010-02-18 10:27:53,877 INFO [EntityBinder.java:422] : Bind entity com.cerner.edi.dep.entity.TxDetail on table TX_DETAIL
    2010-02-18 10:27:53,893 INFO [AnnotationBinder.java:419] : Binding entity from annotated class: com.cerner.edi.dep.entity.TxType
    2010-02-18 10:27:53,893 INFO [EntityBinder.java:422] : Bind entity com.cerner.edi.dep.entity.TxType on table TX_TYPE
    2010-02-18 10:27:53,924 INFO [CollectionBinder.java:650] : Mapping collection: com.cerner.edi.dep.entity.Tx.actions -> TX_ACTION
    2010-02-18 10:27:53,924 INFO [CollectionBinder.java:650] : Mapping collection: com.cerner.edi.dep.entity.Tx.children -> TX
    2010-02-18 10:27:53,924 INFO [CollectionBinder.java:650] : Mapping collection: com.cerner.edi.dep.entity.Tx.details -> TX_DETAIL
    2010-02-18 10:27:53,940 INFO [AnnotationConfiguration.java:369] : Hibernate Validator not found: ignoring
    2010-02-18 10:27:53,940 INFO [LocalSessionFactoryBean.java:730] : Building new Hibernate SessionFactory
    2010-02-18 10:27:53,940 INFO [HibernateSearchEventListenerRegister.java:53] : Unable to find org.hibernate.search.event.FullTextIndexEventListe ner on the classpath. Hibernate Search is not enabled.
    2010-02-18 10:27:53,940 INFO [ConnectionProviderFactory.java:95] : Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSource ConnectionProvider
    2010-02-18 10:27:54,111 INFO [SettingsFactory.java:114] : RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    2010-02-18 10:27:54,111 INFO [SettingsFactory.java:115] : JDBC driver: Oracle JDBC driver, version: 10.2.0.2.0
    2010-02-18 10:27:54,142 INFO [Dialect.java:175] : Using dialect: org.hibernate.dialect.Oracle10gDialect
    2010-02-18 10:27:54,142 INFO [TransactionFactoryFactory.java:62] : Transaction strategy: org.springframework.orm.hibernate3.SpringTransacti onFactory
    2010-02-18 10:27:54,142 INFO [TransactionManagerLookupFactory.java:80] : No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:161] : Automatic flush during beforeCompletion(): disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:165] : Automatic session close at end of transaction: disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:172] : JDBC batch size: 15
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:175] : JDBC batch updates for versioned data: disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:180] : Scrollable result sets: enabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:188] : JDBC3 getGeneratedKeys(): disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:196] : Connection release mode: auto
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:223] : Default batch fetch size: 1
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:227] : Generate SQL with comments: disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:231] : Order SQL updates by primary key: disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:235] : Order SQL inserts for batching: disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:397] : Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    2010-02-18 10:27:54,142 INFO [ASTQueryTranslatorFactory.java:47] : Using ASTQueryTranslatorFactory
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:243] : Query language substitutions: {}
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:248] : JPA-QL strict compliance: disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:253] : Second-level cache: enabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:257] : Query cache: disabled
    2010-02-18 10:27:54,142 INFO [SettingsFactory.java:382] : Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
    2010-02-18 10:27:54,158 INFO [SettingsFactory.java:267] : Optimize cache for minimal puts: disabled
    2010-02-18 10:27:54,158 INFO [SettingsFactory.java:276] : Structured second-level cache entries: disabled
    2010-02-18 10:27:54,158 INFO [SettingsFactory.java:296] : Echoing all SQL to stdout
    2010-02-18 10:27:54,158 INFO [SettingsFactory.java:305] : Statistics: disabled
    2010-02-18 10:27:54,158 INFO [SettingsFactory.java:309] : Deleted entity synthetic identifier rollback: disabled
    2010-02-18 10:27:54,158 INFO [SettingsFactory.java:324] : Default entity-mode: pojo
    2010-02-18 10:27:54,158 INFO [SettingsFactory.java:328] : Named query checking : enabled
    2010-02-18 10:27:54,189 INFO [SessionFactoryImpl.java:193] : building session factory
    2010-02-18 10:27:54,345 INFO [SessionFactoryObjectFactory.java:105] : Not binding factory to JNDI, no JNDI name configured
    2010-02-18 10:27:54,423 INFO [DefaultSingletonBeanRegistry.java:421] : Destroying singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@5976c2: defining beans [org.springframework.context.annotation.internalPer sistenceAnnotationProcessor,org.springframework.co ntext.annotation.internalCommonAnnotationProcessor ,org.springframework.context.annotation.internalAu towiredAnnotationProcessor,org.springframework.con text.annotation.internalRequiredAnnotationProcesso r,entityInterceptor,auditDao,subscriberDaoHbn,txDa o,txTypeDao,txService,oracle_dataSource,oracle_sch emaName,sessionFactory,transactionManager,org.spri ngframework.aop.config.internalAutoProxyCreator,au ditIntercept,org.springframework.aop.support.Defau ltBeanFactoryPointcutAdvisor#0]; root of factory hierarchy
    2010-02-18 10:27:54,439 INFO [AbstractSessionFactoryBean.java:246] : Closing Hibernate SessionFactory
    2010-02-18 10:27:54,439 INFO [SessionFactoryImpl.java:853] : closing

  2. #2
    Join Date
    Feb 2010
    Posts
    12

    Default

    I understand now that the hibernate interce ptor is not of any advise type its just a hibernate interceptor so it cannot be applied as an advise at the service layer level, is there anyway I can make this an advise without changing its functionality.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •