Hi,

I am using a criteria.list() to retrieve a list of people with their travel arrangements, but when I persist some changes to one of those individual's travel arrangements immediately before - these changes are not being picked up.

This is the sequence of events:

presentationBackingBean calls service.saveTravel() which calls dao.attachDirty() which calls getHibernateTemplate().saveOrUpdate()
presentationBackingBean calls service.getTravellers() which calls dao.getTravellers() which calls criteria.list()

My service methods are like this ...

Code:
	public void saveTravel(TravelRef travelRequest, String userId) throws ApplicationException {

		try {
			log.debug("saving port call for travel request " + travelRequest.getTravelId()+");
			travelRefDao.attachDirty(travelRequest);
		}
		catch (Exception e) {
			ZodiacException.handleThrowable(e, userId, this.getClass());
		}
	}

	
	public List<Traveller> getTravellers(String vesselCode, String userId) throws ApplicationException {
		
		List<Traveller> travellerList = null;
		
		try {
			travellerList = personsVoyageDAO.getTravellers(vesselCode);

			....
.... and the relevant DAO methods ...

Code:
	public void attachDirty(TravelRef instance) {
		log.debug("attaching dirty TravelRef instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
		} 
		catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public List<Traveller> getTravellers(String vesselCode) {
		
		Criteria criteria = getSession().createCriteria(Traveller.class)
			.add(Restrictions.eq("vesselCode", vesselCode));

		return criteria.list();
	}

... and my Spring config file:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
   "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <!-- Business Object Beans-->


    <bean id="travelService"
            class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

        <property name="proxyInterfaces">
            <list>
                <value>com.mgms.zodiac.crew.travel.service.TravelService</value>
            </list>
        </property>
        <property name="target">
            <ref bean="travelServiceTarget"/>
        </property>
        <property name="transactionManager">
            <ref bean="hibernateTransactionManager"/>
        </property>
        <property name="transactionAttributeSource">
            <ref bean="transactionAttributeSource"/>
        </property>
    </bean>

    <bean id="travelServiceTarget"
            class="com.mgms.zodiac.crew.travel.service.impl.TravelServiceImpl">
        <property name="personsVoyageDAO">
            <ref bean="personsVoyageDAO"/>
        </property>
        <property name="travelRefDao">
            <ref bean="travelRefDao"/>
        </property>
    </bean>

    ....

    <!--JDBC Transaction Manager-->
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
    </bean>

    <!-- Transaction Attributes -->
    <bean id="transactionAttributeSource" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
        <property name="properties">
            <props>
                <prop key="save*">
                    PROPAGATION_REQUIRED, -ApplicationException
                </prop>
		.....
            </props>
        </property>
    </bean>

    <bean id="transactionAttributeSourceAttendance" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
        <property name="properties">
            <props>
                <prop key="*">
                    PROPAGATION_REQUIRES_NEW, -ApplicationException
                </prop>
            </props>
        </property>
    </bean>

    <!-- DAO Beans-->
    <bean id="jdbcTemplate"
        class="org.springframework.jdbc.core.JdbcTemplate" depends-on="dataSource">
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
    </bean>

    <bean id="personsVoyageDAO"
            class=" com.mgms.zodiac.crew.dao.hibernate.impl.PersonVoyageDAOImpl">

        <property name="hibernateTemplate">
            <ref bean="hibernateTemplate"/>
        </property>
        <property name="sessionFactory">
            <ref bean="sessionFactory"/>
        </property>
    </bean>

    <bean id="travelRefDao"
        class=" com.mgms.zodiac.crew.travel.dao.hibernate.impl.TravelRefDAOImpl">
        <property name="hibernateTemplate">
            <ref bean="hibernateTemplate"/>
        </property>
        <property name="sessionFactory">
            <ref bean="sessionFactory"/>
        </property>
    </bean>

    ....

    <!--Datasource-->
    <bean id="dataSource"
        class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
            <value>java:/danaos</value>
        </property>
    </bean>

    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="hibernateTransactionManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref bean="sessionFactory"/>
    </property>
    </bean>

    <!--Hibernate configuration-->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>

        <property name="configLocation">
            <value>classpath:hibernate.cfg.xml</value>
    </property>
    </bean>

    <bean id="hibernateTemplate"
            class="org.springframework.orm.hibernate3.HibernateTemplate">

        <property name="sessionFactory">
            <ref bean="sessionFactory"/>
        </property>
    </bean>

</beans>
Before service.getTravellers() is called, I can see from the database that the changes have already been persisted. Even though the Traveller.hbm.xml has the associated TravelRef set with a 'lazy=false', the sql logging shows that there is no attempt to re-get the TravelRef instances. I'm assuming that this is because the saveOrUpdate() and the criteria.list() are using different sessions, and the latter one is unaware of the changes - but what should I be doing to make sure that the changes are retrieved?

Hoping someone can help.

Thanks in advance,
Neil