I want to update this table in the Oracle database with SQL Developer
This is my java entity
@Entity
@Table(name = "Users")
public class User {
private int idUser;
private String login;
private String password;
private String actived;
public User() { }
public User( String login, String password ) {
super();
this.setLogin( login );
this.setPassword( password );
}
@Id
@Column(name = "USER_ID", unique = true, nullable = false, scale = 0)
public int getIdUser() {
return idUser;
}
@Column(name = "USER_LOGIN", nullable = false)
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
@Column(name = "USER_PASSWORD", nullable = false)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name = "ACTIVED", length=1)
public String getActived() {
return actived;
}
public void setActived(String actived) {
this.actived = actived;
}
public String toString() {
return this.idUser + ": " + this.login + "/" + this.password
;
}
}
And my service
@Service
@Transactional
public class MyServiceImpl implements MyService {
private static final long serialVersionUID = 8393594103219622298L;
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=? " ;
SQLQuery query = sessionFactory.getCurrentSession().
createSQLQuery(query1);
query.setParameter(0, idUser);
query.executeUpdate();
}
}
And when i call activedMyUser(3, true), In my USERS table the row with id equals 3 is not updated in oracle database with sql developper. I must do a commit after my request, how can i do it programmatically in java. I have no error in my sql native request. How xcan i solve this problem ?