-1

I'm working on a Java Spring Boot with Spring Batch work project, with and Oracle 19 database. We are not using JPA.

There is a relationship between two entities, one of the information needed for entity A is equal to a list of information from entity B. So I'm trying to get the entity A info by going through a method developed for entity B, something like this:

PersistanceEntityB persistEntityB = new PersistanceEntityB();
for(EntityB entityB : listEntityB){
    listInfoEntityB.addAll(persistEntityB.getInfoB(entityB));
}

As you can imagine when I call getInfoB(entityB) in its own class when trying to get the info for entity B, it works, but when I try it from entity A -> entity B, I get the error: "entityManager is null".

I'd like to know why and how to avoid it so that I don't copy pass the method from entity persistance B inside the one used in entity persistence A.

Here is basically how the whole job works:
job begins -> calls step -> calls controller -> calls entity persistance (the rest is not really relevant)

We are using the latest version in everything, except for the database, which is Oracle 19c.

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
  • Please provide a [mre]. BTW, you say you don't use JPA, but the error message talking about entity manager suggests otherwise. – Mark Rotteveel May 19 '22 at 16:30

0 Answers0