我想在oracle数据库中更新我的表,我使用了oraclesql客户机oraclesqldevelopper。
这是我的要求:
@Service
@Transactional
public class MyServiceImpl implements MyService {
private static final long serialVersionUID = 8393594103219622298L;
@Transactional(readOnly=false,propagation=Propagation.REQUIRES_NEW)
public void activedMyUser(int idUser, boolean isActived) {
String query1 = "update USERS";
if(isActived) {
query1 += " set ACTIVED='T' " ;
} else {
query1 += " set ACTIVED='F' " ;
}
query1+= " where USER_ID= " + idUser+ ""
org.hibernate.classic.Session session = sessionFactory.getCurrentSession();
try {
SQLQuery q = session.createSQLQuery(query1);
int res = q.executeUpdate();
System.out.println("Affected row : "+ res);
} catch (Exception exp) {
System.out.println("Erreur lors de la transaction : "+ exp.getMessage());
}
}
}
一切都正常工作,我在eclipse控制台中看到打印消息:“受影响的行:1”;当我转到oraclesqldevelopper时,我看到了我的表,并用他的id检查用户行,该列不会更新。我怎样才能纠正你的错误?请帮忙。
暂无答案!
目前还没有任何答案,快来回答吧!