Hi,
I am tring to update the simple object by using Update query by i am getting following exception
[ObjectDB 2.4.4_15] javax.persistence.TransactionRequiredException
Attempt to run update query when no transaction is active (error 611)
at com.objectdb.jpa.JpaQuery.executeUpdate(JpaQuery.java:758)
Following is the code i am executing
EntityManagerFactory emFactory = Persistence.createEntityManagerFactory(Constants.DATABASE_FILE_CLIENTSERVER_MODE);
EntityManager em = emFactory.createEntityManager();
Query query = em.createQuery(createUpdateQuery(userCredential, sessionID));
int updateCount = query.setParameter("value", userCredential.getRegisteredEmailD()).executeUpdate();
And called method is as follows
private String createUpdateQuery(UserCredential trip, String sessionID){
StringBuffer sqlQuery = new StringBuffer("UPDATE UserCredential p ");
sqlQuery.append(" SET sessionID='"+(sessionID)+"'");
sqlQuery.append(" WHERE 1=1 AND registeredEmailD = ':value'");
return sqlQuery.toString();
}
Kindly provide your views on the same.