Announcement Announcement Module
Collapse
No announcement yet.
calling multiple transactional methods nested within a method using @Transactional Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • calling multiple transactional methods nested within a method using @Transactional

    Hi ,
    I am trying to call a service method which calls other methods (all methods are transactional) using AOP proxy.I know this is not the best approach as it tightly couples the code with aop sematics BUT
    I tried to use aspectj also ...unfortunately I am unable to get the right syntax from documentation and other threads for my purpose.

    THE method call is failing with the 3rd level internal call to a transactional method.Below is the stack trace :

    PHP Code:
    Exception in ReporterService
    org
    .hibernate.PropertyAccessExceptionIllegalArgumentException occurred calling getter of com.gsm.reporter.model.TrkIO.ioid
        at org
    .hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:198)
        
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:227)
        
    at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3850)
        
    at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3558)
        
    at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)
        
    at org.hibernate.engine.ForeignKeys$Nullifier.isNullifiable(ForeignKeys.java:159)
        
    at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:91)
        
    at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:69)
        
    at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:310)
        
    at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203)
        
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:143)
        
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
        
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
        
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
        
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
        
    at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685)
        
    at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677)
        
    at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:252)
        
    at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:392)
        
    at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:335)
        
    at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204)
        
    at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:425)
        
    at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:362)
        
    at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:338)
        
    at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204)
        
    at org.hibernate.engine.Cascade.cascade(Cascade.java:161)
        
    at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:154)
        
    at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:145)
        
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88)
        
    at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
        
    at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1185)
        
    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1837)
        
    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
        
    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
        
    at com.gsm.reporter.service.ReporterServiceImpl.updateBrkDevRecords(ReporterServiceImpl.java:102
            
    etc....
    Caused Byjava.lang.IllegalArgumentExceptionobject is not an instance of declaring class
        
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        
    at java.lang.reflect.Method.invoke(Method.java:597)
        
    at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:172)
        
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:227)
        
    at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3850)
        
    at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3558)
        
    at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)
        
    at org.hibernate.engine.ForeignKeys$Nullifier.isNullifiable(ForeignKeys.java:159)
        
    at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:91)
        
    at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:69)
        
    at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:310)
        
    at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203)
        
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:143)
        
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
        
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
        
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
        
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
        
    at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685)
        
    at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677)
        
    at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:252)
        
    at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:392)
        
    at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:335)
        
    at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204)
        
    at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:425)
        
    at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:362)
        
    at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:338)
        
    at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204)
        
    at org.hibernate.engine.Cascade.cascade(Cascade.java:161)
        
    at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:154)
        
    at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:145)
        
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88)
        
    at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
        
    at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1185)
        
    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1837)
        
    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
        
    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
        
    at com.gsm.reporter.service.ReporterServiceImpl.updateBrkDevRecords(ReporterServiceImpl.java:102)
            
    etc...........
            
    Transaction rolled back because it has been marked as rollback-only
    org
    .springframework.transaction.UnexpectedRollbackExceptionTransaction rolled back because it has been marked as rollback-only
        at org
    .springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:717)
        
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:374)
        
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
        
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        
    at $Proxy59.fireEngine(Unknown Source)
            
    etc........ 
    ALL related files are attched
    MY SERVICE CLASS :ReporterServiceImpl
    MY IMPLEMENTED INTERACE : ReporterService
    My code from where I call intialize the context and call the service : HourlyReporter
    and my config file :context.xml

    I dont understand what I am doing wrong PLEASE HELP
    Also if possible please give me a solution using mode="aspectj" for internal calls on transactional
    methods which doesnt use a proxy.I already have all the required jars I just need to know the
    configuration syntax.

  • #2
    Did you figure out the issue?

    It doesn't seem to be an AOP issue. The problem seems to be coming from
    Code:
    List listBrkDev = subQueryBrkDev.list();
    As this seems to point out
    Code:
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.gsm.reporter.model.TrkIO.ioid 
    .......
    at com.gsm.reporter.service.ReporterServiceImpl.updateBrkDevRecords(ReporterServiceImpl.java:102)
    .....
    Caused By: java.lang.IllegalArgumentException: object is not an instance of declaring class
    Hibernate doesn't seem to like the returned type.

    Though not the cause of the issue but I notice you're using ProxyFactoryBean.

    Code:
    ProxyFactory factory = new ProxyFactory(reporterServiceImpl);
    factory.addInterface(ReporterService.class);
    factory.setExposeProxy(true);
    reporterService = (ReporterService) factory.getProxy();
    You don't need to do this as you should already get an advised bean when you request it from the container. You can debug it and see your bean has the transaction advice applied to it.

    I would just do:
    Code:
    ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[]{"com/gsm/reporter/context.xml"});
    ReporterService reporterServiceImpl = appContext.getBean("reporterService",ReporterService.class);
    reporterService.fireEngine();

    nicolas.loriente
    Last edited by nicolas.loriente; Jun 4th, 2011, 12:52 AM.

    Comment

    Working...
    X