Grails
  1. Grails
  2. GRAILS-5355

Add JPA @Entity support to gorm:sessionFactory

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.2-M4
    • Fix Version/s: None
    • Component/s: Persistence
    • Labels:
      None

      Description

      Modifying GORMSessionFactoryDefinitionParser.java by
      adding the following to private ClassPathBeanDefinitionScanner configureScanner does not due the trick.

              // support for JPA Entity class
              scanner.addIncludeFilter(new AnnotationTypeFilter(javax.persistence.Entity.class));
      

      I get the following exception when trying to add the com.grailstest.Animal @Entity class:

      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.grailstest.AnimalValidator': Error sett
      ing property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
      PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'domainClass' threw exception; nested exception is java.lang.NullPointe
      rException
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1335)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1061)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:543)
      Destroying 1 processes
      Destroying process..    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:730)
      
              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:387)
      Destroyed 1 processes   at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
      
              at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
              at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
              at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
              ... 28 more
      Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
      PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'domainClass' threw exception; nested exception is java.lang.NullPointe
      rException
              at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
              at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:60)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1332)
              ... 42 more
      

      Apparently, for every JPA @Entity the appication is looking for a

      {CLASS_NAME}

      Validator for that entity.

      It would also be nice if it could support @Validateable or static constraints like a JPA Entity object supports directly in Grails.

        Issue Links

          Activity

          Hide
          Scott Murphy added a comment -

          Note I am assuming I don't need to add config-class="org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration", because it looks like GORMSessionFactoryDefinitionParser uses that as default.

          Show
          Scott Murphy added a comment - Note I am assuming I don't need to add config-class="org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration", because it looks like GORMSessionFactoryDefinitionParser uses that as default.
          Hide
          Scott Murphy added a comment -
          Show
          Scott Murphy added a comment - This ticket is related to: http://jira.codehaus.org/browse/GRAILS-5290

            People

            • Assignee:
              Unassigned
              Reporter:
              Scott Murphy
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Last Reviewed:

                Development