-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: bugA general bugA general bug
Milestone
Description
Hello,
did something related to ApplicationContextAware
behaviour change between Spring Boot 3.0.6 and 3.1.0? I have custom Hibernate IdentifierGenerator
that also implements ApplicationContextAware
because it's POJO to access the spring context:
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@NonNullApi
public class SnowflakeIdentifierGenerator implements IdentifierGenerator, ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public Object generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws HibernateException {
return applicationContext.getBean(SnowflakeIdGenerator.class).nextId(); // NPE happens here
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
This works fine with Spring Boot 3.0.6, but after upgrading to 3.1.0, the ApplicationContext
is always null
.
Metadata
Metadata
Assignees
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: bugA general bugA general bug