Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

How to Use Hibernate Annotation & .hbm.xml files at single time on a Same project?

Posted by Pankil Patel on June 11, 2012

Use sessionFactory as org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean in its configuration file instead of org.springframework.orm.hibernate3.LocalSessionFactoryBean

Sample configuration is as below:

<bean id=”sessionFactory”
class=”org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean”>
<property name=”annotatedClasses“>
<list>
<value>co.cc.enlightensoft.model.businessobject.Product</value>
</list>
</property>
<property name=”mappingResources“>
<list>
<value>co/cc/enlightensoft/model/businessobject/Category.hbm.xml</value>
<value>co/cc/enlightensoft/model/businessobject/User.hbm.xml</value>
</list>
</property>

<property name=”hibernateProperties”>
<props>
<prop key=”hibernate.dialect”>org.hibernate.dialect.MySQLDialect</prop>
<prop key=”hibernate.show_sql”>true</prop>
<prop key=”hibernate.cglib.use_reflection_optimizer”>true</prop>
<prop key=”hibernate.cache.provider_class”>org.hibernate.cache.HashtableCacheProvider</prop>
</props>
</property>

<property name=”dataSource”>
<ref bean=”dataSource” />
</property>

</bean>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: