Announcement Announcement Module
No announcement yet.
spring hibernate and axis Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring hibernate and axis


    I have two modules in my application.
    The first one is a webservice. (Axis 1.1, spring 1.1.3 and Hibernate 2.1.6 ) This web service is responsible for
    accessing the database.

    The second one is web application which is consuming this web service. It does not do anything other than presentation.

    The problem I am facing now is, when I request Hibernate for records in one table, it is executing so many queries.
    It is fetching records from the tables which have foreign-key relation with that table. So when the web application is
    using this web service, it is taking lot of time to load the page. ( 20 minutes just to display 5-6 records!!!!). I think this is because Axis is trying to (De)serialize all the objects that are retrieved from the database.

    I tried keeping lazy="true" for all the associations. but by the time, the web appliction is accessing those associations, the session is getting closed causing "session closed exception" . but i am not opening or closing any sessions explicitly..spring is doint that for me. i do not want to tak any control on the sessions and i want to leave that to spring...

    I know that this is a very common requirement and i am missing some basic thing...plz help as performance of my application is really very poor and unacceptable.

    Following is my applicationContext.xml. i removed all the unwanted entries..

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC 
    	<bean id="dataSource"
    		<property name="driverClassName">
    		<property name="url">
    		<property name="username">
    		<property name="password">
    	<!-- Hibernate SessionFactory -->
    	<bean id="sessionFactory"
    		<property name="dataSource">
    			<ref local="dataSource" />
    		<property name="mappingResources">
    		<property name="hibernateProperties">
    				<prop key="hibernate.dialect">
    	<!-- Transaction manager for a single Hibernate SessionFactory &#40;alternative to JTA&#41; -->
    	<bean id="transactionManager"
    		<property name="sessionFactory">
    			<ref local="sessionFactory" />
    	<!-- Add DAOs here -->
    	<bean id="roleDao"
    		<property name="sessionFactory">
    			<ref local="sessionFactory" />
    	<bean id="ProductionService"
    		<property name="transactionManager">
    			<ref local="transactionManager" />
    		<property name="target">
    			<ref local="userManagerTarget" />
    		<property name="transactionAttributes">
    				<prop key="remove*">PROPAGATION_REQUIRED</prop>
    	<bean id="userManagerTarget"
    		<property name="roleDao">
    			<ref local="roleDao" />

  • #2
    Try following Karl Baum's example

    Give that a shot.


    • #3
      I am having the same probelem

      The link provide no longer contains the info. Has anyone founf a fix for this problem?


      • #4
        You'll always have issues in regards to lazy loading and trying to work on the object graph after a proxied method has returned (especially when trying to rewrap your objects into something a bit more usable for web services)

        On your web service methods, the easiest way is to programatically define the transaction boundary, so that your transactional proxied object will join it.

        for example, let's say you have a method caled "getFoo()" in your webservice implementation

               public SomeResult getFoo() {
                    SomeResult someResult = null;
                     PlatformTransactionManager transManager = applicationContext.getBean("transactionManager");
                     DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        		TransactionStatus status = transactionManager.getTransaction(def);
                     try {
                             // call your business objects here
                            // any code in here won't have any problems with lazy loading.
                             // remap to your result here
                             someResult = ....
                     } catch (Throwable error) {
                    return result;
        Or you can create a facade, wrap it up in a transaction declaratively and just make sure you are doing all your re-wrapping inside said method.