[jboss-user] [EJB 3.0] - Re: problem with EJB3 QL

Nicesun do-not-reply at jboss.com
Thu Nov 9 10:14:49 EST 2006


Sure, i guess you have forgotten to do the transaction management on it :

for example this works :

		EntityManager manager = getJpaTemplate().getEntityManagerFactory().createEntityManager();
		
		try {
			manager.getTransaction().begin();
			
			Query query = manager.createQuery("UPDATE Profile p SET p.status=?1 WHERE p.status=?2");
			query.setParameter(1, statusReplacing);
			query.setParameter(2, statusToReplace);
			query.executeUpdate();
			
			manager.getTransaction().commit();
		}
		finally {
			manager.close();
		}
	}

Not that with others providers, the begin/commit is not always necessary, this is why it's confusing. But the hibernate way seems the most logical.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3984544#3984544

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3984544



More information about the jboss-user mailing list