-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Getting error that table refers to an un-mapped class
PostPosted: Thu Sep 11, 2008 2:28 am 
Newbie

Joined: Fri May 02, 2008 1:25 am
Posts: 7
I am getting "
An association from the table user-project refers to an unmapped class: com.sonu.hibernate.pojo.Role" error message.
I am trying to map the TreeMap.

Hibernate version:3.0

Mapping documents:

[ProjectPojo.hbm]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.sonu.hibernate.pojo.ProjectPojo" table="project">
<id name="projectId" column="PROJECT_ID">
<generator class="increment"/>
</id>
<property column="PROJECT_NAME" name="projectName" type="java.lang.String" length="50" unique-key="true"/>
<map name="users" table="user-project" cascade="all">
<key column="PROJECT_ID"/>
<index-many-to-many column="USER_ID" class="com.sonu.hibernate.pojo.Userpojo"/>
<many-to-many column="ROLE_ID" class="com.sonu.hibernate.pojo.Role"/>
</map>
</class>

</hibernate-mapping>


[/ProjectPojo.hbm]

[UserPojo.hbm]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.sonu.hibernate.pojo.UserPojo" table="user">
<id name="userId" column="USER_ID">
<generator class="increment"/>
</id>
<property column="USER_NAME" name="userName" type="java.lang.String" length="50" unique="true"/>
<property column="USER_PASSWORD" name="userPassword" type="java.lang.String" length="50"/>
<map name="projets" table="user-project" cascade="all">
<key column="USER_ID"/>
<index-many-to-many column="PROJECT_ID" class="com.sonu.hibernate.pojo.ProjectPojo"/>
<many-to-many column="ROLE_ID" class="com.sonu.hibernate.pojo.Role"/>
</map>
</class>
</hibernate-mapping>

[/UserPojo.hbm]

[Role.hbm]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.sonu.hibernate.pojo.Role" table="role">
<id name="roleId" column="ROLE_ID" unsaved-value="0">
<generator class="increment"/>
</id>
<property column="ROLE_TYPE" name="roleType" type="java.lang.String" length="20" unique="true"/>

</class>
</hibernate-mapping>

[/Role.hbm]

Code between sessionFactory.openSession() and session.close():

public class UserInsertInToDataBase {
LoggerUtility loggerUtility=new LoggerUtility("c:\\logs\\logFile.log");
Session session=HibernateManager.getCurrentSession();
Logger logger=Logger.getLogger(UserInsertInToDataBase.class);

private ProjectPojo creatProject(){
UserPojo userPojo=new UserPojo();
ProjectPojo projectPojo=new ProjectPojo();
projectPojo.setProjectName("Project 1");
TreeMap projects=new TreeMap(new ProjectComparator());
projects.put(projectPojo, new Role("MANAGER"));
userPojo.setProjets(projects);
TreeMap users=new TreeMap(new UserComparator());
users.put(userPojo, new Role("MANAGER"));
projectPojo.setUsers(users);

return projectPojo;
}

private boolean insertProjectIntoDataBase(ProjectPojo projectPojo){
boolean isAdded= false;
logger.debug("The method has started");
try{
if(session!=null){
Transaction transaction=session.beginTransaction();
session.save(projectPojo);
transaction.commit();
isAdded=true;
}
}catch(HibernateException ex){
logger.debug("The following exception has occured"+ex.getMessage());
}
logger.debug("The method has completed");
return isAdded;
}

public static void main(String[] args){
UserInsertInToDataBase userInsertInToDataBase=new UserInsertInToDataBase();
ProjectPojo local_project=userInsertInToDataBase.creatProject();
boolean isAdded=userInsertInToDataBase.insertProjectIntoDataBase(local_project);
}
}

Full stack trace of any exception that occurs:

2008-09-11 11:40:09,587 (Environment.java:500) INFO - Hibernate 3.2 cr3
2008-09-11 11:40:09,837 (Environment.java:533) INFO - hibernate.properties not found
2008-09-11 11:40:09,962 (Environment.java:667) INFO - Bytecode provider name : cglib
2008-09-11 11:40:10,290 (Environment.java:584) INFO - using JDK 1.4 java.sql.Timestamp handling
2008-09-11 11:40:12,212 (Configuration.java:1350) INFO - configuring from resource: /hibernate.cfg.xml
2008-09-11 11:40:12,259 (Configuration.java:1327) INFO - Configuration resource: /hibernate.cfg.xml
2008-09-11 11:40:13,868 (DTDEntityResolver.java:38) DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
2008-09-11 11:40:13,946 (DTDEntityResolver.java:40) DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
2008-09-11 11:40:14,103 (DTDEntityResolver.java:50) DEBUG - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
2008-09-11 11:40:14,993 (Configuration.java:1311) DEBUG - connection.url=jdbc:mysql://localhost:3306/basicstrutsdatabase
2008-09-11 11:40:15,040 (Configuration.java:1311) DEBUG - connection.driver_class=com.mysql.jdbc.Driver
2008-09-11 11:40:15,103 (Configuration.java:1311) DEBUG - connection.username=root
2008-09-11 11:40:15,165 (Configuration.java:1311) DEBUG - connection.password=admin
2008-09-11 11:40:15,212 (Configuration.java:1311) DEBUG - connection.autocommit=true
2008-09-11 11:40:15,275 (Configuration.java:1311) DEBUG - show_sql=true
2008-09-11 11:40:15,337 (Configuration.java:1311) DEBUG - dialect=org.hibernate.dialect.MySQLDialect
2008-09-11 11:40:15,415 (Configuration.java:1510) DEBUG - null<-org.dom4j.tree.DefaultAttribute@1579a30 [Attribute: name resource value "com/sonu/hibernate/pojo/ProjectPojo.hbm.xml"]
2008-09-11 11:40:15,478 (Configuration.java:507) INFO - Reading mappings from resource: com/sonu/hibernate/pojo/ProjectPojo.hbm.xml
2008-09-11 11:40:15,665 (DTDEntityResolver.java:38) DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
2008-09-11 11:40:15,759 (DTDEntityResolver.java:40) DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
2008-09-11 11:40:15,931 (DTDEntityResolver.java:50) DEBUG - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
2008-09-11 11:40:22,150 (HbmBinder.java:299) INFO - Mapping class: com.sonu.hibernate.pojo.ProjectPojo -> project
2008-09-11 11:40:22,618 (HbmBinder.java:1269) DEBUG - Mapped property: projectId -> PROJECT_ID
2008-09-11 11:40:23,056 (HbmBinder.java:1269) DEBUG - Mapped property: projectName -> PROJECT_NAME
2008-09-11 11:40:23,212 (HbmBinder.java:1411) INFO - Mapping collection: com.sonu.hibernate.pojo.ProjectPojo.users -> user-project
2008-09-11 11:40:23,400 (HbmBinder.java:1269) DEBUG - Mapped property: users
2008-09-11 11:40:23,478 (Configuration.java:1510) DEBUG - null<-org.dom4j.tree.DefaultAttribute@19e11a1 [Attribute: name resource value "com/sonu/hibernate/pojo/UserPojo.hbm.xml"]
2008-09-11 11:40:23,540 (Configuration.java:507) INFO - Reading mappings from resource: com/sonu/hibernate/pojo/UserPojo.hbm.xml
2008-09-11 11:40:23,728 (DTDEntityResolver.java:38) DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
2008-09-11 11:40:23,821 (DTDEntityResolver.java:40) DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
2008-09-11 11:40:24,009 (DTDEntityResolver.java:50) DEBUG - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
2008-09-11 11:40:29,040 (HbmBinder.java:299) INFO - Mapping class: com.sonu.hibernate.pojo.UserPojo -> user
2008-09-11 11:40:29,150 (HbmBinder.java:1269) DEBUG - Mapped property: userId -> USER_ID
2008-09-11 11:40:29,259 (HbmBinder.java:1269) DEBUG - Mapped property: userName -> USER_NAME
2008-09-11 11:40:29,368 (HbmBinder.java:1269) DEBUG - Mapped property: userPassword -> USER_PASSWORD
2008-09-11 11:40:29,478 (HbmBinder.java:1411) INFO - Mapping collection: com.sonu.hibernate.pojo.UserPojo.projets -> user-project
2008-09-11 11:40:29,571 (HbmBinder.java:1269) DEBUG - Mapped property: projets
2008-09-11 11:40:29,650 (Configuration.java:1465) INFO - Configured SessionFactory: null
2008-09-11 11:40:29,743 (Configuration.java:1466) DEBUG - properties: {hibernate.connection.password=admin, java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=C:\Program Files\Java\jdk1.6.0\jre\bin, java.vm.version=1.6.0-b105, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 4, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\NetBeansWorkspace\BasicStrutsApplication, java.runtime.version=1.6.0-b105, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\Java\jdk1.6.0\jre\lib\endorsed, os.arch=x86, hibernate.connection.autocommit=true, java.io.tmpdir=C:\DOCUME~1\UMASHA~1.SHA\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows 2000, sun.jnu.encoding=Cp1252, java.library.path=C:\Program Files\Java\jdk1.6.0\jre\bin;.;C:\WINNT\Sun\Java\bin;C:\WINNT\system32;C:\WINNT;c:\QC\tools\bin;c:\cygwin\usr\local\bin;c:\cygwin\bin;c:\cygwin\sbin;d:\oracle\product\10.2.0\client_1\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Java\jdk1.6.0\bin;c:\PROGRA~1\cvsnt;d:\Java\Python;c:\Program Files\JProbe 7.0\bin;c:\apache-ant-1.6.5\bin;c:\Program Files\Java\jdk1.6.0;C:\Program Files\CVSNT\, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.0, connection.password=admin, user.home=C:\Documents and Settings\umashankar.sharma, user.timezone=GMT+05:30, connection.username=root, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.6, hibernate.connection.driver_class=com.mysql.jdbc.Driver, show_sql=true, user.name=umashankar.sharma, java.class.path=C:\NetBeansWorkspace\BasicStrutsApplication\build\web\WEB-INF\classes;C:\Program Files\NetBeans 6.0\enterprise4\modules\ext\struts\antlr.jar;C:\Program Files\NetBeans 6.0\enterprise4\modules\ext\struts\commons-beanutils.jar;C:\Program Files\NetBeans 6.0\enterprise4\modules\ext\struts\commons-digester.jar;C:\Program Files\NetBeans 6.0\enterprise4\modules\ext\struts\commons-logging.jar;C:\Program Files\NetBeans 6.0\enterprise4\modules\ext\struts\commons-validator.jar;C:\Program Files\NetBeans 6.0\enterprise4\modules\ext\struts\jakarta-oro.jar;C:\Program Files\NetBeans 6.0\enterprise4\modules\ext\struts\struts.jar;C:\Program Files\NetBeans 6.0\enterprise4\modules\ext\commons-fileupload-1.0.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\antlr-2.7.6.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\asm-attrs.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\asm.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\cglib-2.1.3.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\commons-collections-2.1.1.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\commons-logging-1.0.4.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\dom4j-1.6.1.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\hibernate3.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\jta.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\log4j-1.2.11.jar;C:\NetBeansWorkspace\BasicStrutsApplication\web\WEB-INF\lib\mysql-connector-java-3.1.13-bin.jar;C:\NetBeansWorkspace\BasicStrutsApplication\src\conf;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\annotations-api.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\catalina-tribes.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\tomcat-i18n-es.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\tomcat-i18n-ja.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\tomcat-i18n-fr.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\tomcat-coyote.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\catalina-ant.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\catalina-ha.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\tomcat-dbcp.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\servlet-api.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\jasper-el.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\catalina.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\jsp-api.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\jasper.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\el-api.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\tomcat-juli.jar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\jdk1.6.0\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost:3306/basicstrutsdatabase, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.6.0, java.ext.dirs=C:\Program Files\Java\jdk1.6.0\jre\lib\ext;C:\WINNT\Sun\Java\lib\ext, sun.boot.class.path=C:\Program Files\Java\jdk1.6.0\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0\jre\classes, java.vendor=Sun Microsystems Inc., connection.driver_class=com.mysql.jdbc.Driver, file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, connection.autocommit=true, sun.desktop=windows, connection.url=jdbc:mysql://localhost:3306/basicstrutsdatabase, dialect=org.hibernate.dialect.MySQLDialect, sun.cpu.isalist=}
2008-09-11 11:40:30,040 (Configuration.java:1209) DEBUG - Preparing to build session factory with filters : {}
2008-09-11 11:40:30,087 (Configuration.java:1044) DEBUG - processing extends queue
2008-09-11 11:40:30,150 (Configuration.java:1048) DEBUG - processing collection mappings
2008-09-11 11:40:30,212 (CollectionSecondPass.java:33) DEBUG - Second pass for collection: com.sonu.hibernate.pojo.ProjectPojo.users
2008-09-11 11:40:31,978 (CollectionSecondPass.java:49) DEBUG - Mapped collection key: PROJECT_ID, index: USER_ID, element: ROLE_ID
2008-09-11 11:40:32,040 (CollectionSecondPass.java:33) DEBUG - Second pass for collection: com.sonu.hibernate.pojo.UserPojo.projets
2008-09-11 11:40:32,165 (CollectionSecondPass.java:49) DEBUG - Mapped collection key: USER_ID, index: PROJECT_ID, element: ROLE_ID
2008-09-11 11:40:32,228 (Configuration.java:1059) DEBUG - processing native query and ResultSetMapping mappings
2008-09-11 11:40:32,275 (Configuration.java:1067) DEBUG - processing association property references
2008-09-11 11:40:32,321 (Configuration.java:1089) DEBUG - processing foreign key constraints
2008-09-11 11:40:32,384 (Configuration.java:1172) DEBUG - resolving reference to class: com.sonu.hibernate.pojo.ProjectPojo
2008-09-11 11:40:32,446 (Configuration.java:1172) DEBUG - resolving reference to class: com.sonu.hibernate.pojo.Role
2008-09-11 11:40:35,931 (HibernateManager.java:31) ERROR - The following exception has occured
An association from the table user-project refers to an unmapped class: com.sonu.hibernate.pojo.Role
2008-09-11 11:40:37,900 (HibernateManager.java:32) ERROR - [Ljava.lang.StackTraceElement;@1df5f21


Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.