We have a DB with a User table that has a column of type Tinyint (Since it is a boolean) and we are working with Hibernate. My User model has a variable, autogenerated, of type Byte to designate that user value (setters & getters).
The thing is that inside this method:
public boolean CreateJudge(int idusuario){
boolean newJ = false;
try{
newJ = true;
this.session = Hibernate.getSessionFactory().getCurrentSession();
Usuario newJudge = new Usuario(master.setJuez((byte) 1), idusuario);
session.save(newJudge);
session.close();
}catch (Exception e){
e.printStackTrace();
}
return newJ;
}
What I want is to be able to give that value 1 to the byte and thus force that user to be a judge.
Any ideas? The proposed code does not work and I have already tried:
Usuario newJudge = new Usuario(master.setJuez(1), idusuario);
After thinking about it for a while I have found the solution to my problem myself (something very basic):
We generate a new user in this case: newJudge; and we force a Byte juz = 1, knowing that whenever we call the CreateJudge(); what we are doing is creating a user who is a judge.
I add:
In case someone wanted a way to update an existing User object inside the DB, they would simply have to do the following:
As you can see, we extract the object from the database, store it temporarily in our method and change the value of Judge to 1, thus achieving the update.