java - Hibernate mapping when cfg file and entity file are in different folders -
i've got project structure:
when i'm trying access dtb via hibernate, exception:
initial sessionfactory creation failed.org.hibernate.mappingexception: entity class not found: user/dbuser v 02, 2013 9:17:10 odp. org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet [mvc-dispatcher] in context path [/fit] threw exception [handler processing failed; nested exception java.lang.exceptionininitializererror] root cause java.lang.classnotfoundexception: user/dbuser
could please show me, how should path in config files like? i've tried several combinations, can't figure out, how write it.
dbuser.hbm.xml
:
<?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="dontknowwhatshallbehere/dbuser" table="dbuser"> <id name="userid" type="int"> <column name="user_id" precision="5" scale="0" /> <generator class="assigned" /> </id> <property name="username" type="string"> <column name="username" length="20" not-null="true" /> </property> <property name="createdby" type="string"> <column name="created_by" length="20" not-null="true" /> </property> <property name="createddate" type="date"> <column name="created_date" length="7" not-null="true" /> </property> </class> </hibernate-mapping>
hibernate.cfg.xml
:
<?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-configuration public "-//hibernate/hibernate configuration dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.bytecode.use_reflection_optimizer">false</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> <property name="hibernate.connection.password">password</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3049/test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.dialect">org.hibernate.dialect.mysqldialect</property> <property name="show_sql">true</property> <mapping resource="dontknowwhatshallbehere/dbuser.hbm.xml"></mapping> </session-factory> </hibernate-configuration>
everything looks alright. can try , see : <class name="user.dbuser" table="dbuser">
Comments
Post a Comment