Announcement Announcement Module
No announcement yet.
configuring hibernate jndi sessionfactory Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 id="daoTarget" class="com.caec.amis.dao.basemn.BasedbmnDaoImpl">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>

    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>

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


  • #2
    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.