jpa使用原生SQL update和insert

@Test
public void testExecuteUpdate(){
String jpql = "UPDATE Customer c SET c.lastName = ? WHERE c.id = ?";
Query query = entityManager.createQuery(jpql).setParameter(1, "YYY").setParameter(2, 12);

query.executeUpdate();

}



em.createNativeQuery("insert into user (name, password) values (?, ?)").setParameter(1, "zhangsan").setParameter(2, "zhangsan");

你可能感兴趣的:(j2ee,jpa,&,hibernate,&,mybatis)