hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.02k stars 1.32k forks source link

New SearchBuilder dependency injection causes problems #2193

Open ruoat opened 3 years ago

ruoat commented 3 years ago

Why is HapiFhirLocalContainerEntityManagerFactoryBean injected here because only myEntityManagerFactory.getDataSource() is used? We prefer to use Spring Boot generated LocalContainerEntityManagerFactoryBean instead of HapiFhirLocalContainerEntityManagerFactoryBean so this autowiring breaks our code. Could you change this to

@Autowired
private DataSource dataSource;

and use

JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

in row 352?

Originally posted by @ruoat in https://github.com/jamesagnew/hapi-fhir/pull/2086#r529395918

ruoat commented 3 years ago

actually even simpler modification is to change this:

@Autowired
private HapiFhirLocalContainerEntityManagerFactoryBean myEntityManagerFactory;

to

@Autowired
private LocalContainerEntityManagerFactoryBean myEntityManagerFactory;

and the rest of the code should work with or without HapiFhirLocalContainerEntityManagerFactoryBean. @jamesagnew we have to maintain a patched version of this so it would be very nice if the change could be done to official repository. :)

jamesagnew commented 3 years ago

If you wanted to submit a PR with that change, it would be accepted.

That said, we do all of our performance testing against the settings that are set in HapiFhirLocalContainerEntityManagerFactoryBean so I'd say that not using it wouldn't be our recommendation.