I am trying to get data from the database by using code below. I am pretty sure that the query is correct but I always get this "DatabaseError: current transaction is aborted, commands ignored until end of transaction block". How can I fix it?
Transaction tx;
tx = persistence.getTransaction()
if (tx == null)
tx = persistence.createTransaction()
def entityManager = persistence.getEntityManager()
dpArray = entityManager.createNativeQuery(dpSelectQuery, DeliveryPoint.class)
.setParameter('contract', contract)
.getResultList()
tx.end()