Announcement Announcement Module
No announcement yet.
sessionFactory only called once in applicationContext-security.xml? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • sessionFactory only called once in applicationContext-security.xml?

    Hallo agains,

    An issue I'm unsure of atm, I have hibernate handling my logins through a user table. If this table is manipulated whilst the app is running, no change takes place on the login side of things (however they do on tables, I'm using ZK for that and can see the changes correctly).
    So if I log in with:
    admin password

    Then change the password to newpassword

    I have to clean & build the app, then run it before the change takes place for the login.
    So in other words I think it only checks the user table data once, keeps it somewhere?

    Anyway code I think might help:

    snippet of applicationContext-security.xml
        <beans:bean id="sesFactory"
            <beans:property name="configLocation">
    	<beans:bean id="userDAO" class="login.UserLoginDAOImpl">
                    <beans:property name="sessionFactory" ref="sesFactory"></beans:property>
    	<beans:bean id="userService" class="login.UserLoginService">
    		<beans:property name="userDAO" ref="userDAO"></beans:property>
             <authentication-provider user-service-ref="userService">
             	<!--<password-encoder hash="sha" />-->
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
            <!-- Database connection settings -->
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="connection.url">jdbc:mysql://localhost:3306/test</property>
            <property name="hibernate.connection.username">root</property>
            <property name="hibernate.connection.password">admin</property>
            <!-- JDBC connection pool (use the built-in) -->
            <property name="connection.pool_size">1</property>
             <!-- Enable Hibernate's automatic session context management -->
            <property name="current_session_context_class">thread</property>
            <!-- Disable the second-level cache -->
            <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
            <!-- SQL dialect -->
            <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
            <!-- Echo all executed SQL to stdout -->
            <property name="show_sql">true</property>
            <mapping class="contacts.Contacts" />
            <mapping class="login.Users" />

  • #2
    Once the user is logged in, the value is cached in the HttpSession for performance reasons. Please see for an example. Alternatively, you can provide your own SecurityContextRepository implementation that does not use the cached value in session (you will want to ensure this performs though).