-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Processing several @PersistenceContext injection points on the same class with AOT generates code that does not compile #30437
Comments
Sounds like this is related to spring-projects/spring-data-jpa#2753 / #29796. |
Hard to say without access to the sample. @kartik-kaushik Could you please make the file accessible? |
@sdeleuze sorry for that. I have made it accessible now. Kindly download and confirm. |
Looks a bit different I think. If I take the repro, I have a repository bean with 2 persistence contexts: public class DBSyncDAOImpl {
@PersistenceContext(unitName = "CUSTDB")
@Qualifier("entityManagerFactory")
private EntityManager customDBEntityManager;
@PersistenceContext(unitName = "EMS")
@Qualifier("customDBEntityManagerFactory")
private EntityManager customDBEntityManager2;
// ...
} And the injection code generated is: public static DBSyncDAOImpl apply(RegisteredBean registeredBean, DBSyncDAOImpl instance) {
Field field = ReflectionUtils.findField(DBSyncDAOImpl.class, "customDBEntityManager");
ReflectionUtils.makeAccessible(field);
ReflectionUtils.setField(field, instance, getCUSTDBEntityManager(registeredBean));
Field field = ReflectionUtils.findField(DBSyncDAOImpl.class, "customDBEntityManager2");
ReflectionUtils.makeAccessible(field);
ReflectionUtils.setField(field, instance, getEMSEntityManager(registeredBean));
return instance;
} Which does not compile because, well, there are 2 variable @christophstrobl How related does it look like from your POV? |
@sdeleuze you're right - thanks for having a look! I think we should move the issue to |
Good issue to view and learn out of. Thanks to all. |
Spring native app issue with PersistenceContext annotation
we have application with spring boot 3.0.4 which connect to oracle DB.
application build fine normally but for native application is failling if we have more than one PersistenceContext annotation
error: [ERROR] variable field is already defined in method apply(org.springframework.beans.factory.support.RegisteredBean,com.codingknownsense.oraclespringboot.dao.DBSyncDAOImpl)
Sample app location:
https://drive.google.com/file/d/1d373KxaTa73IHkN6rU_NerhXvTBToM04/view?usp=share_link
Kindly help in the same.
The text was updated successfully, but these errors were encountered: