Hi guys,
I have a web application that I developed using Hibernate, Spring and Struts.
I would like to integrate it with Hibernate Search. However, I've never used Hibernated Search before and they are not a lot of examples out there for Hibernate + Spring.
Can any one of you smarties please help me out in integrating Hibernate Search + Spring? Or point me to tutorials that will give me a start? How can I add Hibernate Search to my current configuration?
Here's my code:
Code:
<!-- Local DataSource that works in any environment -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value></property>
<property name="url"><value>jdbc:sqlserver://localhost:1433;databaseName=RX</value></property>
<property name="username"><value>sa</value></property>
<property name="password"><value>myP@sswrd</value></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="dataSource" />
</property>
<property name="mappingResources">
<list> <value>config/BusinessCbo.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">com.PBCoreApp.hibernate.PBSQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.max_fetch_depth">1</prop>
<prop key="hibernate.default_schema">RX</prop>
</props>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory"><ref bean="sessionFactory"/>
</property>
</bean>
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<bean id="businessBSTarget" class="com.PBCoreApp.business.impl.BusinessBSImpl">
<property name="businessDao"><ref local="businessDao" /></property>
</bean>
<bean id="businessBS" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref local="businessBSTarget" /></property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,-Exception</prop> </props>
</property>
</bean>
<bean id="businessDao" class="com.PBCoreApp.dataaccess.impl.BusinessDAOImpl"><property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
....
My DAO class....
Code:
public class BusinessDAOImpl extends HibernateDaoSupport implements BusinessDAO
{
public List findByBusinessId(Object businessId)
{
List resultList =this.getHibernateTemplate().find(
"FROM BusinessCbo AS B "
+ "WHERE B.busines."
+ BUSINESS_ID + "= ?",
businessId);
return resultList;
}
}
Thanks in advance!!!