Announcement Announcement Module
Collapse
No announcement yet.
Hibernate does not work under web application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate does not work under web application

    Hi,
    I have a program which works under ordinary java application, but it does not work under web, why?
    My program will provide a user manager for acegi.

    ===========================
    public boolean changePassword(final String user, String password) {
    String salt = (String) PasswordSaltSource.newSalt();
    final String encPassword = passwordEncoder.encodePassword(password,
    salt);
    List users = this.getHibernateTemplate().find("from User where username='" + user + "'");
    User u = (User) users.get(0);
    u.setPassword(encPassword);
    logger.info(password);
    logger.info(encPassword);
    logger.info(u.getUserName());
    logger.info(u.getPassword());
    this.getHibernateTemplate().saveOrUpdate(u);
    return true;
    }
    ===============================

    hibernate sql are :
    =================================
    Hibernate: select user0_.username as username, user0_.password as password0_, user0_.enabled as enabled0_ from exchange.users user0_ where username='admin'
    Hibernate: update exchange.users set password=?, enabled=? where username=?
    =================================
    and log as:
    =================================
    2005-11-25 08:49:45,131 INFO [com.ourbsd.uum.UserDaoHibernate] - <1>
    2005-11-25 08:49:45,131 INFO [com.ourbsd.uum.UserDaoHibernate] - <bf097d33811b62e2d681bb9b945ebb006a8e7b1c6c28f6894 cc8817dc282c508>
    2005-11-25 08:49:45,131 INFO [com.ourbsd.uum.UserDaoHibernate] - <admin>
    2005-11-25 08:49:45,131 INFO [com.ourbsd.uum.UserDaoHibernate] - <bf097d33811b62e2d681bb9b945ebb006a8e7b1c6c28f6894 cc8817dc282c508>
    =================================

    User.hbm.xml
    =================================
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="com.ourbsd.uum" schema="exchange">

    <class name="User" table="users">

    <id name="userName" column="username" type="string" length="63"/>

    <property name="password" column="password" type="string" length="64"/>

    <property name="enabled" column="enabled" type="boolean"/>

    <bag name="authorities" inverse="true" cascade="all">
    <key column="username"/>
    <one-to-many class="Authority"/>
    </bag>
    </class>


    </hibernate-mapping>
    ======================================

    Authority.hbm.xml
    ======================================
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="com.ourbsd.uum" schema="exchange">

    <class name="Authority" table="authorities">
    <composite-id>
    <key-many-to-one name="user" column="username">
    </key-many-to-one>
    <key-property name="authority" length="63">
    </key-property>
    </composite-id>
    </class>

    </hibernate-mapping>
    ======================================

    I use tomcat 5.5.12, postgresql 8.1.0,Spring 1.2.6, Hibernate 3.0.5, Windows XP, eclipse + M7 plugins.
    Thanks!

  • #2
    I change database into MySQL, no problem occures.

    I don't know why.

    I use postgresql 8.1.0 and postgresql-8.1-404.jdbc3.jar.

    any help?

    Thx.

    Comment

    Working...
    X