Hibernate: not mapped error


A

Amit Jain

Hi
I'm starting to learn hibernate. I found a problem in my code. I have
made the database table in MYSQL with name "userinfo" and I also made
a mapping file. But I get the following error :

org.hibernate.hql.ast.QuerySyntaxException: MemberVO is not mapped.
[from MemberVO]
at
......
Caused by: MemberVO is not mapped.
.... 22 more

I used the code from several examples I found on the www which should
work but in my case they don't.
This is the code to show the list:
============ MemberDAOImpl.java Start
=========
package com.mycomp.crtracker.dao;
public class MemberDAOImpl extends HibernateDaoSupport implements
DataAccessObject{
public ValueObject findByPK(String primaryKey) throws
DataAccessException {
***
**
List myList = session.createQuery("from MemberVO").list();
***
**
}
}
============ MemberDAOImpl.java END
=========

============ hibernate.cfg.xml Start
===========
<?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.dialect">org.hibernate.dialect.MySQLDialect</property>
<property
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</
property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:
3306/crtracker</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</
property>
<mapping resource="com/yashbinary/crtracker/vo/h_mapping/
userinfo.hbm.xml"/>
</session-factory>
</hibernate-configuration>
============ userinfo.hbm.xml END
===========

============ userinfo.hbm.xml
Start===========
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Feb 3, 2009 5:28:33 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="com.amdocs.crtracker.vo.MemberVO" table="userinfo"
catalog="crtracker">
<id name="userId" type="string">
<column name="USERID" length="15" />
<generator class="assigned" />
</id>
<property name="firstName" type="string">
<column name="FIRSTNAME" length="15" />
</property>
<property name="lastName" type="string">
<column name="LASTNAME" length="15" />
</property>
<property name="email" type="string">
<column name="EMAIL" length="15" />
</property>
<property name="password" type="string">
<column name="PASSWORD" length="15" />
</property>
<property name="memberId" type="java.lang.Integer">
<column name="MEMBERID" unique="true" />
</property>
</class>
</hibernate-mapping>

============ hibernate.cfg.xml
END===========

============ hibernate.reveng.xml
Start===========
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate
Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/
hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
<schema-selection match-catalog="crtracker"/>
<table-filter match-name="userinfo"/>
</hibernate-reverse-engineering>
============ hibernate.reveng.xml
END===========

============ MemberVO.java Start
=========
package com.mycomp.crtracker.vo;
public class MemberVO extends ValueObject implements Serializable{
private String memberId;
private String firstName;
private String lastName;
private String userId;
private String password;
private String email;
/*setters and getters for all above listed*/
}
============ MemberVO.java END =========
 
Ad

Advertisements

L

Lew

Amit said:
I'm starting to learn [H]ibernate. I found a problem in my code. I have
made the database table in MYSQL with name "userinfo" and I also made
a mapping file. But I get the following error :

org.hibernate.hql.ast.QuerySyntaxException: MemberVO is not mapped.
[from MemberVO]
at
.....
Caused by: MemberVO is not mapped.
... 22 more

I used the code from several examples I found on the www which should
work but in my case they don't.
This is the code to show the list: ....
<hibernate-mapping>
<class name="com.amdocs.crtracker.vo.MemberVO" table="userinfo"
catalog="crtracker"> ....
package com.mycomp.crtracker.vo;
public class MemberVO extends ValueObject implements Serializable{

Your <hibernate-mapping> specifies a different class from the one you show.
It specifies com.amdocs.crtracker.vo.MemberVO and you show
com.mycomp.crtracker.vo.MemberVO.
 
A

Amit Jain

Amit said:
I'm starting to learn [H]ibernate. I found a problem in my code. I have
made the database table in MYSQL with name "userinfo" and I also made
a mapping file. But I get the following error :
org.hibernate.hql.ast.QuerySyntaxException: MemberVO is not mapped.
[from MemberVO]
at
.....
Caused by: MemberVO is not mapped.
... 22 more
I used the code from several examples I found on the www which should
work but in my case they don't.
This is the code to show the list: ...
<hibernate-mapping>
    <class name="com.amdocs.crtracker.vo.MemberVO" table="userinfo"
catalog="crtracker"> ...
package com.mycomp.crtracker.vo;
public class MemberVO extends ValueObject implements Serializable{

Your <hibernate-mapping> specifies a different class from the one you show.
It specifies com.amdocs.crtracker.vo.MemberVO and you show
com.mycomp.crtracker.vo.MemberVO.

It's a typing mistake, I am sorry for that.

In <hibernate-mapping> I specified com.mycomp.crtracker.vo.MemberVO.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top