Affects: 5.2.3.RELEASE

Hopefully this is not a bug, though I didn't have success looking for information around the net - not even searching on StackOverflow (where I previously asked a question too).

Given a @Repository annotated class like:

@Repository
public class Dao extends JdbcDaoSupport {

    @Autowired
    private DataSource dbDataSource;

    @PostConstruct
    private void initialize() throws Exception {
        setDataSource(dbDataSource);
    }

    /* ... */

Can I have a class like this (note the @Service annotation there)?

@Service
public class Service extends Dao {
    /* ... */

Because Service appears to have no jdbcTemplate - when I call getJdbcTemplate() it get null.

If I get rid of @Repository on Dao, or replace it with @Service it works.

Comment From: watery

After some debugging, I discovered that the issue only arises in a Spring (Boot?) managed Quartz Job*, where the service is provided to the job like this:

*: the application where I experience this issue is a Spring Boot one.

@DisallowConcurrentExecution
public class Job extends QuartzJobBean {

    private Service service;

    @Autowired
    public void setService(Service service) {
        this.service = service;
    }

    /* ... */

}

When @Repository is on Dao, PersistenceExceptionTranslationPostProcessor ultimately replaces my bean with a proxy-generated one, on which the @PostConstruct annotated method is not being called, thus leaving my underlying dao / service uninitialized.

I've tracked down the replacement in PersistenceExceptionTranslationPostProcessor superclass AbstractAdvisingBeanPostProcessor, inside method postProcessAfterInitialization(Object, String).

Comment From: snicoll

Because Service appears to have no jdbcTemplate - when I call getJdbcTemplate() it get null.

It's very hard to understand what you're trying to describe. @Service is just an alias for @Component so as long as the class is picked up by classpath scanning and Spring creates a bean for it, it should be fine. Perhaps that's not the case? I can't say for sure. If you want support, please take the time to share a small sample that we can run ourselves. You can do so by attaching a zip to this issue or sharing the code on a separate GitHub repository.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.