I am new to JSF and Hibernate so I am sorry if this question is simple for here.
I am using MySQL database and my users table has a boolean column. Hibernate mapped the value in hbm.xml as
<property name="verified" type="boolean">
<column name="verified" not-null="true"/>
</property>
When I run the query using the HQL Query Window in NetBeans
update Users set verified = false where email = '[email protected]'
it perfectly sets the boolean value true and false. But in my helper class I have this method to set the value
public void setIsVerified(Users user, Boolean isVerified){
Transaction tx = null;
try{
tx = session.beginTransaction();
Query q = session.createQuery("update Users set verified = :verified where email = :email");
q.setParameter("verified", isVerified);
q.setParameter("email", user.getEmail());
q.executeUpdate();
}catch(RuntimeException e){
if(tx != null)
tx.rollback();
throw e;
}
}
but it doesn't set the value. I tried setting the value manually as q.setParameter("verified", true); it also didn't work. (email is unique field, I also tried using ID field which is primary key.)
Interesting part is when I run this method using JUnit it doesn't produce any error message or warning. It seems it works perfectly but doesn't change the value in the database.
Any tip will be appreciated since I don't get any messages I don't know where to search for. I don't know what happens in the background. Thanks in advance..