-
Notifications
You must be signed in to change notification settings - Fork 617
Declare the dependency between shared session creator and entity instantiator. #2099
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
You removed the order, right? And the issue still persists… I'll have a look. |
Yes, I am struggling with the order of initialization of spring beans. @order was not working. |
Could you please post an example of your converter logic? |
See this example reproduction: repro_converion_npe.zip Start the test, then it fails. Uncomment the workaround lines in MyMigration component it and runs green. Hope that helps. |
Yeah, I can work with that. Btw, I hope you don't have that base class in production: @NodeEntity
public abstract class EntityBase {
@Id
@GeneratedValue
private Long graphId;
@Id
@GeneratedValue(strategy = UuidStrategy.class)
private String uuid;
} This is 100% guaranteed to cause pain somewhere. You are basically defining two ids here. |
What that work for you? @Component
public class MigrationLogic implements ApplicationListener<ContextRefreshedEvent> {
private @Autowired ThingRepository userRepository;
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
// Do your migration
}
} Otherwise I would like to pull in @mp911de here. I have no idea why the thing is picked up too late. |
…ntity instantiator. The conversion service is picked up to late as the the dependency between the shared session creator and the bean that does the post processing of the underlying session factory is undefined for the Spring context. By explicit stating this in the repository extension, the `Neo4jOgmEntityInstantiatorConfigurationBean` is correctly initialized upfront without messing around with an actual post processor or orderings. This closes #2099.
As stated in the initial comment, I cannot use Regarding the two IDs: I need the UUID as usual ID. The graph ID is needed because I do some manual wiring of configured (not known at compile time) relations when quering and the query is returning Thanks for looking into the issue. |
…ntity instantiator. The conversion service is picked up to late as the the dependency between the shared session creator and the bean that does the post processing of the underlying session factory is undefined for the Spring context. By explicit stating this in the repository extension, the `Neo4jOgmEntityInstantiatorConfigurationBean` is correctly initialized upfront without messing around with an actual post processor or orderings. This closes #2099.
This is fixed and will be included in the next patch releases in February. Thank you for your contribution, @steffen-harbich-cognitum |
…ntity instantiator. The conversion service is picked up to late as the the dependency between the shared session creator and the bean that does the post processing of the underlying session factory is undefined for the Spring context. By explicit stating this in the repository extension, the `Neo4jOgmEntityInstantiatorConfigurationBean` is correctly initialized upfront without messing around with an actual post processor or orderings. This closes #2099.
I have a database migration script component as in the following code:
Produces the NullPointerException:
This is because
Neo4jOgmEntityInstantiatorConfigurationBean
has not been initialized at that point. I would expect it to be initialized once the repositories are available as spring bean. I need to run the migration script before tomcat embedded is opening REST API ports, so I cannot use an event like "context refreshed" to do the migration.Workaround: Add
which is of course an unwanted hack.
The text was updated successfully, but these errors were encountered: