I used one mapping file user.hbm.xml is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.rml.UserBean" table="User">
<property name="firstName" column="first_name"/>
<property name="lastName" column="last_name"/>
<property name="password" column="password"/>
</class>
</hibernate-mapping>
I have created user table in mysql
Please help it
mahest2001 wrote:
I am getting this error when integrating Hibernate with Spring
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: invalid mapping
This is my applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/rml</value></property>
<property name="username"><value>mm</value></property>
<property name="password"><value>mm</value></property>
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="myDataSource"/></property>
<property name="mappingResources">
<list>
<value>/com/rml/user.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
</value>
</property>
</bean>
<bean id="userdao" class="com.rml.UserDAO">
<property name="sessionFactory"><ref bean="mySessionFactory"/></property>
</bean>
</beans>
In the Spring I used as
<bean id="userController" class="com.rml.UserController">
<property name="userdao"><ref bean="userdao"/></property>
</bean>
Please help me How to solve this error