Results 1 to 2 of 2

Thread: configuring hibernate jndi sessionfactory

  1. #1
    Join Date
    Aug 2004
    Location
    ChengDu,China
    Posts
    3

    Default configuring hibernate jndi sessionfactory

    Hi all.

    I use spring+hibernate+weblogic8.1.2. I write a EJB using spring ejb implments,hibernate sessionfactory has already startup when weblogic 8.1 start,configured a jndi resource.

    But I confused how to write the sevice-layercontext.xml,look like this:

    <bean id="sessionFactory" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName"><value>hibernate</value></property>
    </bean>

    <bean id="daoTarget" class="com.caec.amis.dao.basemn.BasedbmnDaoImpl">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>

    BasedbmnDaoImpl implments HibernateDaoSupport,So its hibernate sessionfactory can not cast from Jndiobject to hibernate session factory property

    Look like as follow is right,I configure the hibernate sessonfactory to a LocalSessionFactoryBean,so I remove the jndiobject of hibernate from weblogic startup Class.
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="configLocation"><value>com/caec/amis/ctx/service/Hibernate.cfg.xml</value></property>
    </bean>

    Then It is only solution to hibernate sessionfactory using LocalSessionFactoryBean by spring.
    Any help will be appreciated.

    Thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    JndiObjectFactoryBean is a standard Spring FactoryBean. As described in the manual and JavaDocs, FactoryBeans return a specific object, and their type for setting properties is considered to be the type of the object they return. So just reference the JndiObjectFactoryBean in the sessionFactory property, and if the JNDI object is in fact a SessionFactory, you will have no problems.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Replies: 6
    Last Post: Apr 28th, 2010, 07:57 AM
  2. Replies: 4
    Last Post: Apr 2nd, 2008, 03:22 PM
  3. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Replies: 7
    Last Post: Aug 21st, 2004, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •