0

Jpa configuration loads the essential beans, scans entities and enables repositories. Based on some condition at run time, I would like to add a few more packages to be scanned for entities and repositories and wire them in bean factory. The extra packages to be scanned is available only at run time.

@Configuration
@EnableJpaRepositories
@EntityScan
@PropertySource(value = "classpath:jpa.properties")
@EnableTransactionManagement(proxyTargetClass = true)
@EnableJpaAuditing
public class JpaConfiguration {

    ...
    ...

    public void condition(){
        if(someCondition){
            //scan more entities
            //enable more repositories
        }
    }  
}

Is it possible to do something like this?

FFL
  • 669
  • 7
  • 22
  • Might this be relevant to you? http://stackoverflow.com/questions/18423019/how-to-enable-load-time-runtime-weaving-with-hibernate-jpa-and-spring-framewor – Anders R. Bystrup May 28 '15 at 08:42
  • Nope. It is about enhancing an entity already scanned by spring/hibernate. – FFL May 28 '15 at 09:51
  • EntityScan and EnableJpaRepositories accepts a _basePackages_ attribute. You could use this with a SPEL expression to retrieve a value from the properties file. Are these packages available in the classpath at runtime? – jrao77 May 28 '15 at 10:11

0 Answers0