I'll begin by saying that I have not done any customization of any of the caching mechanisms within hibernate. I have up to now just let the default ride. I'll show my hibernate.cgf.xml file, my HibernateFilter, and relavent mapping files as the situation calls for it. I am using Hibernate 3 RC4
hibernate.cfg.xml HibernateFilter Ok, let's start with caching issue #1.
Issue #1 ----------------------
I have a column in my database that stores a tinyint. 0 means the account is not active, 1 means the account is active. In my login action, if the username and password pass, I check this value and either return an error message or pass into the webapp. What is happening is after the webapp starts and I login, if I go into the database and change the tinyint value and I try and login again, it is still pulling the old value. I have to restart the webapp to get it to pull the new value. So I am assuming that it is not reading the database again, it is just pulling the value from cache somewhere, but I don't know enough about how it works to figure it out.
User.hbm.xml User.java public class User implements Serializable
{
private Integer userId;
private
String username;
private String password;
private String firstName;
private String lastName;
private String emailAddress;
private String role;
private boolean active;
public User() { }
public Integer getUserId()
{
return userId;
}
public void setUserId(Integer userId)
{
this.userId = userId;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getFirstName()
{
return firstName;
}
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
public String getLastName()
{
return lastName;
}
public void setLastName(String lastName)
{
this.lastName = lastName;
}
public String getEmailAddress()
{
return emailAddress;
}
public void setEmailAddress(String emailAddress)
{
this.emailAddress = emailAddress;
}
public String getRole()
{
return role;
}
public void setRole(String role)
{
this.role = role;
}
public boolean isActive(){
return this.active;
}
public void setActive(boolean active) {
this.active = active;
}
public boolean isAdmin()
{
if (this.role.equals(Constants.ROLE_ADMIN)){
return true;
}else{
return false;
}
}
}
[/code]
Login code snippet HibernateUserDAO.java