Announcement Announcement Module
Collapse
No announcement yet.
bug in DependencyInjectionInterceptor ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • bug in DependencyInjectionInterceptor ?

    I've been using DependencyInjectionInterceptor for hibernate from the sandbox for a moment with no probems.
    Today I tried to fetch a list of elements having composite ids and I got a NullPointerException.
    Here's the stack trace:
    Code:
    NullPointerException
    	at org.springframework.beans.BeanWrapperImpl.getNestedPropertySeparatorIndex(BeanWrapperImpl.java:423)
    	at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:458)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:666)
    	at org.springframework.orm.hibernate.support.ChainedInterceptorSupport.setIdOnNewEntity(ChainedInterceptorSupport.java:191)
    	at org.springframework.orm.hibernate.support.DependencyInjectionInterceptorFactoryBean$DependencyInjectionInterceptor.instantiate(DependencyInjectionInterceptorFactoryBean.java:112)
    	at net.sf.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1792)
    	at net.sf.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1785)
    	at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:577)
    	at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
    	at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
    	at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
    	at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
    	at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
    	at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
    	at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
    	at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
    	at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
    	at org.springframework.orm.hibernate.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:633)
    	at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:243)
    	at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:263)
    	at org.springframework.orm.hibernate.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:624)
    	at org.springframework.orm.hibernate.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:619)
    ...
    Is it a bug ?

  • #2
    I am able to use it just fine with the newest Spring version

    Comment


    • #3
      It works fine for me too with objects that have "simple" id. The exception was thrown form BeanWraperImpl when I used an object with a composite id although the object was accepted by Hibernate. That's why I think it's a bug.

      Comment


      • #4
        I'm using it as well with an object with a composite id and it is working fine for me.

        Have you tried to see if everything is bound correctly to your object before you query?

        --Rexxe

        Comment


        • #5
          Are you getting this with the latest version of the DependencyInjectionInterceptorFactoryBean from CVS?

          If so, please raise an issue in JIRA. Although it's sandbox code, it will migrate to Spring core fairly quickly, so we're happy to accept issues on it.

          Rgds
          Rod

          Comment


          • #6
            I've added an issue:
            http://opensource.atlassian.com/proj...browse/SPR-564
            The NPE is thrown because the call to sessionFactory.getClassMetadata(persistentClass).g etIdentifierPropertyName() in ChainedInterceptorSupport returns null in my case. According to hibernate's javadoc, null is a possible value when you call public String getIdentifierPropertyName():
            Get the name of the identifier property (or return null)

            Comment


            • #7
              Originally posted by Rod Johnson
              Although it's sandbox code, it will migrate to Spring core fairly quickly, so we're happy to accept issues on it.

              Rgds
              Rod
              I can not find this code in Spring 1.2 Final. Has it been renamed or deprecated?

              Thanks,
              Corby

              Comment


              • #8
                You can find the issue here:
                http://opensource.atlassian.com/proj...browse/SPR-564.
                I also submitted the patch in Jan but I think it wasn't review because the interceptor has been postponed for 1.4RC1.
                You need to get the source from the CVS and the patch from JIRA (using the link above).

                Comment


                • #9
                  This was not included in the 1.2 release, as indivated in JIRA. Ultimately I think the best way of doing this is an AOP approach. AspectJ 5 integration will allow annotated classes to be dependency injected by Spring, regardless of how they're created (new, ORM framework etc). It's also possible without dependency on a particular API such as Hibernate.

                  Nevertheless, I know Java 5, let along AspectJ 5 isn't an option for many users, so I'll try to look at the issue soon and consider releasing for 1.3.

                  Comment


                  • #10
                    Originally posted by Rod Johnson
                    This was not included in the 1.2 release, as indivated in JIRA. Ultimately I think the best way of doing this is an AOP approach. AspectJ 5 integration will allow annotated classes to be dependency injected by Spring, regardless of how they're created (new, ORM framework etc). It's also possible without dependency on a particular API such as Hibernate.

                    Nevertheless, I know Java 5, let along AspectJ 5 isn't an option for many users, so I'll try to look at the issue soon and consider releasing for 1.3.
                    I was wondering if someone could explain how this is done with Java 5 and AspectJ. I am currently using transaction annotations on my service methods, but I have a HibernateUserType which needs injection. I am currently using the DependencyInjectionInterceptorFactoryBean, but would love to get away from it.

                    Thanks for any help,

                    Rexxe

                    Comment

                    Working...
                    X