Why am I receiving the exception below if the type of both entities is PersistentLogin? I thought that would mean they are in the same entity group, but I guess that is an incorrect assumption. Any ideas how to fix this?
This is the code:
// the class is marked with @Transactional
@Override
public final void removeUserTokens(final String username) {
final Query query = entityManager.createQuery(
"SELECT p FROM PersistentLogin p WHERE username = :username");
query.setParameter("username", username);
for (Object token : query.getResultList()) {
entityManager.remove(token);
}
}
This is the exception:
Caused by: javax.persistence.PersistenceException: Illegal argument
at org.datanucleus.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:260)
at org.datanucleus.jpa.EntityTransactionImpl.commit(EntityTransactionImpl.java:122)
at org.datanucleus.store.appengine.jpa.DatastoreEntityTransactionImpl.commit(DatastoreEntityTransactionImpl.java:50)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:467)
... 42 more
Caused by: java.lang.IllegalArgumentException: can't operate on multiple entity groups in a single transaction. found both Element {
type: "PersistentLogin"
name: "1WfCYx8bmwUGkjzP2PpmFA=="
}
and Element {
type: "PersistentLogin"
name: "SfI0P8RVBjTvu0WHMSuaVA=="
}