Spring JavaConfig
  1. Spring JavaConfig
  2. SJC-150

Create sample demonstrating effective JPA use with JavaConfig

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0.M4
    • Component/s: Samples
    • Labels:
      None

      Description

      Several users have asked about best practices with regard to JPA, transaction management, etc. Create a sample and reference it from documentation.

      1. SJC150.patch
        37 kB
        Arul Dhesiaseelan

        Activity

        Hide
        Arul Dhesiaseelan added a comment -

        Hi Chris,

        I have implemented the JpaConfiguration for the PetClinic sample. I have attached the trunk sources including the new code for the org.springframework.config.java.samples.petclinic sample. The new set of Jpa tests are working with this new Jpa based configuration. I have tested with embedded data source config as well as external data source config. So, users can easily switch to the configuration they need. There are couple tests commented in AbstractJpaClinicTests which may not be relevant when using AbstractTransactionalJUnit4SpringContextTests. Please review these files and let me know if this integration is what you expected.

        Modified files:
        trunk\src\test\java\test\web\InContainerTests.java (Test supports JDBC as wells JPA based data access)
        trunk\pom.xml (Added dependencies for implementing Hibernate based JPA data access layer)
        trunk\src\main\webapp\WEB-INF\web.xml (Added JpaPetclinicApplicationConfig to the context param.

        Added Files:
        trunk\src\main\java\org\springframework\samples\petclinic\config\JpaPetclinicApplicationConfig.java
        trunk\src\main\java\org\springframework\samples\petclinic\jpa\EntityManagerClinic.java (Added from Spring Framework 2.5.5 samples distribution)
        trunk\src\test\java\org\springframework\samples\petclinic\jpa\AbstractJpaClinicTests.java (Added from Spring Framework 2.5.5 samples distribution. Modified the test to run using the JpaPetclinicApplicationConfig))
        trunk\src\test\java\org\springframework\samples\petclinic\jpa\EntityManagerClinicTests.java (Added from Spring Framework 2.5.5 samples distribution. Modified the test to run using the JpaPetclinicApplicationConfig)
        trunk\src\main\resources\META-INF\aop.xml (Added from Spring Framework 2.5.5 samples distribution)
        trunk\src\main\resources\META-INF\orm.xml (Added from Spring Framework 2.5.5 samples distribution)
        trunk\src\main\resources\META-INF\persistence.xml (Added from Spring Framework 2.5.5 samples distribution)

        Cheers,
        Arul

        Show
        Arul Dhesiaseelan added a comment - Hi Chris, I have implemented the JpaConfiguration for the PetClinic sample. I have attached the trunk sources including the new code for the org.springframework.config.java.samples.petclinic sample. The new set of Jpa tests are working with this new Jpa based configuration. I have tested with embedded data source config as well as external data source config. So, users can easily switch to the configuration they need. There are couple tests commented in AbstractJpaClinicTests which may not be relevant when using AbstractTransactionalJUnit4SpringContextTests. Please review these files and let me know if this integration is what you expected. Modified files: trunk\src\test\java\test\web\InContainerTests.java (Test supports JDBC as wells JPA based data access) trunk\pom.xml (Added dependencies for implementing Hibernate based JPA data access layer) trunk\src\main\webapp\WEB-INF\web.xml (Added JpaPetclinicApplicationConfig to the context param. Added Files: trunk\src\main\java\org\springframework\samples\petclinic\config\JpaPetclinicApplicationConfig.java trunk\src\main\java\org\springframework\samples\petclinic\jpa\EntityManagerClinic.java (Added from Spring Framework 2.5.5 samples distribution) trunk\src\test\java\org\springframework\samples\petclinic\jpa\AbstractJpaClinicTests.java (Added from Spring Framework 2.5.5 samples distribution. Modified the test to run using the JpaPetclinicApplicationConfig)) trunk\src\test\java\org\springframework\samples\petclinic\jpa\EntityManagerClinicTests.java (Added from Spring Framework 2.5.5 samples distribution. Modified the test to run using the JpaPetclinicApplicationConfig) trunk\src\main\resources\META-INF\aop.xml (Added from Spring Framework 2.5.5 samples distribution) trunk\src\main\resources\META-INF\orm.xml (Added from Spring Framework 2.5.5 samples distribution) trunk\src\main\resources\META-INF\persistence.xml (Added from Spring Framework 2.5.5 samples distribution) Cheers, Arul
        Hide
        Chris Beams added a comment -

        Arul,

        Could you re-submit this as a patch? It will help expedite the process of my reviewing it.

        Also note that petclinic has been modified recently, after you submitted these changes. So the best thing to do would be update your repository, make sure your changes still work, and then 'svn diff > diff.patch'. Make sure to 'svn add' any new files before doing the diff..

        Thanks again.

        Show
        Chris Beams added a comment - Arul, Could you re-submit this as a patch? It will help expedite the process of my reviewing it. Also note that petclinic has been modified recently, after you submitted these changes. So the best thing to do would be update your repository, make sure your changes still work, and then 'svn diff > diff.patch'. Make sure to 'svn add' any new files before doing the diff.. Thanks again.
        Hide
        Arul Dhesiaseelan added a comment -

        Hi Chris,

        Please find the attached patch. I updated the svn and then created this patch after all unit tests ran successfully.

        -Arul

        Show
        Arul Dhesiaseelan added a comment - Hi Chris, Please find the attached patch. I updated the svn and then created this patch after all unit tests ran successfully. -Arul
        Hide
        Chris Beams added a comment -

        Thanks Arul! Your patch has been committed after some modification. To switch between JDBC and JPA, simply modify the commented param-value of the contextConfigLocation context-param in web.xml.

        Show
        Chris Beams added a comment - Thanks Arul! Your patch has been committed after some modification. To switch between JDBC and JPA, simply modify the commented param-value of the contextConfigLocation context-param in web.xml.
        Hide
        Arul Dhesiaseelan added a comment -

        Thanks Chris.

        Show
        Arul Dhesiaseelan added a comment - Thanks Chris.

          People

          • Assignee:
            Chris Beams
            Reporter:
            Chris Beams
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development