arbiter22 wrote:
i am new to hibernate annotation
am trying to use hibernate annotaion with spring
flollowing is my code
the problem is that table is not geting created
I'd recommend using the AnnotationSessionFactoryBean instead, which is an extension of LocalSessionFactoryBean. If all you keep in hibernate.cfg.xml is your mappings you can thereby eliminate this (though I'd suggest you put your datasource parameters here).
Using AnnotationSessionFactoryBean is you give it a list of annotated classes:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="annotatedClasses">
<list>
<value>org.employee.model.Employee</value>
</list>
</property>
<property name="configLocation">
<value>WEB-INF/hibernate.cfg.xml</value></property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.max_fetch_depth">3</prop>
</props>
</property>
</bean>
Also make sure you use Hibernate
3.2 or newer, and that you use the @Entity annotation from javax.persistence.*, not Hibernate's.
Hope that helps!
See also
http://www.onjava.com/pub/a/onjava/2007 ... tions.html for a gentle introduction to Hibernate annotations.
And btw, this should probably been posted on the Spring forums. :)