Hi,
I am describing you the following scenario:
1) Use a php page to enter a new user inside my table.
2) Use my JBOSS application to inquiry my user through the following line of code:
private OutMessage login(SuDeTPSession s, UserLoginMsg msg)
throws BaseException {
User user;
String username = (String) msg.getField(UserLoginMsg.USERNAME);
String pwd = (String) msg.getField(UserLoginMsg.PWD);
try {
List users = s.session.createCriteria(
User.class).add(
Expression.eq("userName", username)).list();
// Users are unique per userId or username (see registration process).
if (users != null && users.size() > 0) {
user = (User) users.get(0);
} else {
throw new BaseException(ErrorIds.USER_INVALID_USER);
}
} catch (HibernateException ex) {
throw new BaseException(ErrorIds.USER_INVALID_USER, ex);
}
if (!HashUtil.getMD5(pwd).equals(user.getPassword())) {
throw new BaseException(ErrorIds.USER_INVALID_USER_PWD);
}
if (user.getStatus().equals(IUser.PENDING_REGISTRATION)) {
throw new BaseException(ErrorIds.USER_PENDING_USER);
}
msg.setField(UserLoginMsg.USER, user);
return msg;
}
I need to call this method twice to see the new users I just entered.
Here is my configuration file:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- properties -->
<property name="connection.username">xxx</property>
<property name="connection.password">xxx</property>
<property name="connection.url">jdbc:mysql://localhost/sudetp</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">@hibernate-showsql@</property>
<property name="cglib.use_reflection_optimizer">true</property>
<!-- mapping files -->
<mapping resource="com/etil/sudetp/business/manager/user/impl/User.hbm.xml" />
</session-factory>
</hibernate-configuration>
AM I MISSING SOMETHING WITH THE CACHING?
Thanks.
David
|