Results 1 to 2 of 2

Thread: JPA and how to explicitely list managed classes in the spring configuration

  1. #1
    Join Date
    Jun 2006
    Location
    Linz, Austria (Europe)
    Posts
    30

    Question JPA and how to explicitely list managed classes in the spring configuration

    I'm trying to find a way to list all managed (i.e. persistent) classes within the entity manager factory (or some other spring managed bean) in order to avoid listing them in META-INF/persistence.xml. The LocalEntityManagerFactoryBean already allows to configure the persistence provider class (which is part of the persistence.xml). I would assume that it should be possible that also the class listing could be moved the the EMF configuration.

    The reason for this approach is to reduce the number of configuration files required and to avoid classpath scanning of annotated classes (yes, all of the managed classes are JPA annotated)!

    Is this already supported? Anybody who has tried to do something similar? Would appreciate any tips on how to proceed with this task! Thanks

  2. #2
    Join Date
    Jun 2006
    Location
    Linz, Austria (Europe)
    Posts
    30

    Lightbulb

    Meanwhile I was able to find a first solution myself. I'm sharing this idea in case somebody else needs this too.

    I had a look at the LocalContainerEntityManagerFactoryBean which offers a hook for post processing persistence units that have been retrieved from the found META-INF/persistence.xml. A post processor implementing the interface PersistenceUnitPostProcessor is allowed to modify the persistence unit attributes since it receives a MutablePersistenceUnitInfo.

    So my implementation of the post processor just clears all the managedClasses from the persistence unit info that was passed and adds a list of managedClasses (that are configured as a property of type string list).

Tags for this Thread

Posting Permissions

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