I am new with cuba studio. I am trying to write code that read data from the database in a different table and set the data in another table using the middleware(service). Please do scan through the bellow code and explain to me where i went wrong. erro is: NullPointerException. Your help will be highly appreciated. Thank you
@Override
public void populateFixtures() {
try (Transaction tx = persistence.createTransaction()) {
TypedQuery<Teams> query = persistence.getEntityManager().createQuery("select e from transnamibfootballleague$Teams e", Teams.class);
List<Teams> teamList = query.getResultList();
Teams team = new Teams();
Fixtures fixt = new Fixtures();
for (int i = 0; i < teamList.size(); i++){
fixt.setTeam1(team.getName());
fixt.setTeam2(team.getName());
persistence.getEntityManager().persist(fixt);
}
tx.commit();