Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 984645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:02:54+00:00 2026-05-16T05:02:54+00:00

So, my problem is : All my project is (well ?) configured but I

  • 0

So, my problem is : All my project is (well ?) configured but I don’t have lazy loading !

This a sample project I’m making to prepare the real project coming just after.
In simple words, I have 3 tables : Category, Product, Client, and the association between the last two, Buy.

On the Flex side I have two simple datagrid, the first one contains the products, and the second one contains the clients associated with the selected product.
On the server side a Spring-BlazeDS-Integration architecture and a service which retrieves all the products.

My config files :
web.xml

enter code here

<web-app>
    <display-name>Spring BlazeDS Integration</display-name>
    <description>Spring BlazeDS Integration</description>

    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/config/applicationContext.xml</param-value>
    </context-param>

    <filter>  
        <filter-name>openSessionInViewFilter</filter-name>  
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
        <init-param>
            <param-name>flushMode</param-name>
            <param-value>ALWAYS</param-value>
        </init-param>    
    </filter>

    <filter-mapping>  
        <filter-name>openSessionInViewFilter</filter-name>  
        <url-pattern>/messagebroker/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>Spring MVC Servlet Dispatcher</servlet-name>
        <display-name>Spring MVC Servlet Dispatcher</display-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/config/webApplicationContext.xml</param-value>
       </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>RDSDispatchServlet</servlet-name>
        <servlet-class>flex.rds.server.servlet.FrontEndServlet</servlet-class>
        <init-param>
            <param-name>messageBrokerId</param-name>
            <param-value>_messageBroker</param-value>
        </init-param>        
        <init-param>
            <param-name>useAppserverSecurity</param-name>
            <param-value>false</param-value>
        </init-param>        
        <load-on-startup>10</load-on-startup>
    </servlet>

    <servlet-mapping id="RDS_DISPATCH_MAPPING">
        <servlet-name>RDSDispatchServlet</servlet-name>
        <url-pattern>/CFIDE/main/ide.cfm</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Spring MVC Servlet Dispatcher</servlet-name>
        <url-pattern>/messagebroker/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
    </welcome-file-list>
</web-app>

applicationContext.xml

<beans xmlns="..">
    <bean id="transactionProxy" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager" ref="txManager" />
        <property name="transactionAttributes">
            <props>
                <prop key="create*">PROPAGATION_REQUIRED</prop>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
                <prop key="delete*">PROPAGATION_REQUIRED</prop>
                <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
            </props>
        </property>
    </bean>

    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref local="sessionFactory"/>
        </property>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="mappingResources">
            <list>
                <value>tuto/Product.hbm.xml</value>
                <value>tuto/Client.hbm.xml</value>
                <value>tuto/Category.hbm.xml</value>
                <value>tuto/Buy.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
        <property name="dataSource"><ref bean="dataSource"/></property>
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/tuto" />
        <property name="username" value="root" />
    </bean>
</beans>

webApplicationContext.xml

<beans xmlns=".....">
    <bean id="hibernate-lazy-adapter" class="org.springframework.flex.core.ManageableComponentFactoryBean">
        <constructor-arg value="net.digitalprimates.persistence.hibernate.HibernateAdapter"/>
        <property name="properties">
            <value>
                {
                    "hibernate": {
                        "sessionFactory": {"class":"net.digitalprimates.persistence.hibernate.utils.SpringSessionUtil", "getCurrentSessionMethod":"getCurrentSession"
                        }, "loadMethod":"load"
                    }
                }
            </value>
        </property>
    </bean>

    <flex:message-broker>
        <flex:remoting-service default-adapter-id="hibernate-lazy-adapter" default-channels="my-amf" />
    </flex:message-broker>

    <bean id="productService" parent="transactionProxy">
        <property name="target">
            <bean class="tuto.ServiceProductImpl">
                <property name="productDAO"><ref bean="productDAO"/></property>
            </bean>
        </property>
        <flex:remoting-destination/>
    </bean>

    <bean id="productDAO" class="tuto.DAOProductHibernate" lazy-init="default">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
</beans>

product.hbm.xml

<hibernate-mapping package="tuto">
    <class name="Product" table="product">
        <id name="productId" type="long" column="product_id">
            <generator class="increment"/>
        </id>

        <property name="name" column="name" type="string" not-null="true" length="40"/>

        <many-to-one name="category" column="category_id" class="Category" not-null="true" lazy="false">
        </many-to-one>

        <set name="clients" table="buy" cascade="delete">
            <key column="product_id"/>
            <many-to-many column="client_id" class="Client"/>
        </set>
    </class>
</hibernate-mapping>

And here’s the code in ProductDAO.java

public Collection<Product> findAll() {
    Session session = SessionFactoryUtils.getSession(getSessionFactory(), false);
    try {
        return session.createQuery("from Product").list();
    } catch (HibernateException e) {
        throw SessionFactoryUtils.convertHibernateAccessException(e);
    }
}

If you need more information to help, please ask, I just didn’t want to post to much code in the first message 🙂

So as you can see I just retrieve the products from the database, but when I select a product in the datagrid, the client’s datagrid is populated, so the Clients are loaded too !
Plus, I have a log trace and I can see there is more than one request on the Product table, there’s also several on the Client table.
In my opinion only one should be here ! No ?!

I’m waiting for your suggestion, thanks a lot !

Arnaud.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:02:54+00:00Added an answer on May 16, 2026 at 5:02 am

    Problem solved !

    Change this :

    <flex:message-broker>
        <flex:remoting-service default-adapter-id="hibernate-lazy-adapter" default-channels="my-amf" />
    </flex:message-broker>
    

    to this :

    <flex:message-broker>
    </flex:message-broker>
    

    And in all the beans, change this :

    <flex:remoting-destination/>
    

    to this :

    <flex:remoting-destination service-adapter="hibernate-lazy-adapter" channels="my-amf"/>
    

    Now it works 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the problem: We have all of our development under subversion, but our
I have a strange problem with VS2008. My solution has 8 projects (all c#)
So I'm been pounding on this problem all day. I've got a LinqDataSource that
This is a common problem for all developers, I am looking for the best
I have the problem, that PHP replaces all spaces with underscores in POST and
I have a problem. I'd like to match all occurrences of \t in my
I have problem with return statment >.< I want to store all magazine names
I have one project where the code-signing popup is all whacked-out. On a normal
Scenario You've got several bug reports all showing the same problem. They're all cryptic
An XSLT-newbie problem: I need to substitute a text value in XML-file. All other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.