Announcement Announcement Module
Collapse
No announcement yet.
Example Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Example Spring

    Hi,
    I have to write example EJB use Spring + Hibernate that can run on Application server as: Orion, WebSphere... and can run servlet container such as Tomcat. It's mean that example can run EJB or non EJB.
    Has anyone have example like that. Can you post it here.
    Thank for reading!

  • #2
    Example Spring

    Has anyone have that example.
    Please help me soon!
    Thank for reading!

    Comment


    • #3
      <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
      <property name="jndiName">
      <value>EmsDataSource</value>
      </property>
      </bean>
      <!-- Hibernate SessionFactory -->
      <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
      <property name="dataSource"><ref bean="dataSource"/></property>
      <property name="mappingResources">
      <list>
      <value>com/xxx/*.hbm.xml</value>
      </list>
      </property>
      <property name="hibernateProperties">
      <props>
      <prop key="hibernate.dialect">net.sf.hibernate.dialect.I nformixDialect</prop>
      <prop key="hibernate.show_sql">false</prop>
      <prop key="hibernate.cglib.use_reflection_optimizer">tru e</prop>
      <prop key="hibernate.cache.provider_class">net.sf.hibern ate.cache.HashtableCacheProvider</prop>
      <!--prop key="hibernate.hbm2ddl.auto">update</prop-->
      </props>
      </property>
      </bean>
      <!-- Spring Data Access Exception Translator Defintion -->
      <bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCo deSQLExceptionTranslator">
      <property name="dataSource"><ref bean="dataSource"/></property>
      </bean>

      <!-- Hibernate Template Defintion -->
      <bean id="hibernateTemplate" class="org.springframework.orm.hibernate.Hibernate Template">
      <property name="sessionFactory"><ref bean="sessionFactory"/></property>
      <property name="jdbcExceptionTranslator"><ref bean="jdbcExceptionTranslator"/></property>
      </bean>

      <!-- Hibernate Transaction Manager Definition -->
      <bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
      <property name="sessionFactory"><ref local="sessionFactory"/></property>
      </bean>
      <bean id="txProxyTemplate" abstract="true"
      class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
      <property name="transactionManager">
      <ref local="transactionManager"/>
      </property>
      <property name="transactionAttributes">
      <props>
      <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
      <prop key="create*">PROPAGATION_REQUIRED</prop>
      <prop key="update*">PROPAGATION_REQUIRED</prop>
      <prop key="remove*">PROPAGATION_REQUIRED</prop>
      </props>
      </property>
      </bean>

      <bean id="emsResourceService" parent="txProxyTemplate">
      <property name="target">
      <ref local="emsResourceServiceTarget"/>
      </property>
      </bean>
      <bean
      id="emsResourceServiceTarget"
      class="com.xxx.service.impl.EmsEquipmentServiceImp l">

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

      <bean
      id="equipmentDao"
      class="com.xxx.dao.spring.hibernate.EquipmentDaoHi bernateImpl">
      <property name="hibernateTemplate">
      <ref bean="hibernateTemplate"/>
      </property>
      </bean>

      that configuration file is tested in Weblogic8.1

      Comment


      • #4
        Do I need applicationContext in my ejb ear file?

        I'm still puzzled by Spring configuration for a ear file. Do I need an applicationContext.xml file? Seems like the only xml file I need is beanRefContext.xml. Correct. By the way, where do I put the xml files in the ear file? under APP-INF/class? or META-INF/? If I need to set up logging inside the ear file, where do I put the log4j.properties or log4j.xml and can spring pick it up automatically?

        Thanks.

        Comment

        Working...
        X