-->
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.  [ 2 posts ] 
Author Message
 Post subject: One-to-many exceptions?
PostPosted: Mon Nov 10, 2003 10:20 am 
Newbie

Joined: Sat Nov 08, 2003 12:39 am
Posts: 7
Trying to build a one-to-many relationship for first time and getting some errors like:


[ERROR] XMLHelper - -Error parsing XML: XML InputStream(19) <org.xml.sax.SAXParseException: Attribute "inverse" must be
declared for element type "set".>org.xml.sax.SAXParseException: Attribute "inverse" must be declared for element type "s
et".
at weblogic.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1292)
at weblogic.apache.xerces.validators.common.XMLValidator.validateElementAndAttributes(XMLValidator.java:3778)
at weblogic.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1242)
at weblogic.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1838)
at weblogic.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1207)
at weblogic.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:399)
at weblogic.apache.xerces.framework.XMLParser.parse(XMLParser.java:1138)
at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:133)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:838)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
at Test.main(Test.java:40)

[INFO] Binder - -Mapping class: com.ibm.hibernate_article.Employee -> employee
[INFO] Configuration - -Mapping resource: com/ibm/hibernate_article/Department.hbm.xml
[INFO] Binder - -Mapping class: com.ibm.hibernate_article.Department -> department
[INFO] Configuration - -Configured SessionFactory: HibernateFactory
[INFO] Configuration - -processing one-to-many association mappings
Exception in thread "main" net.sf.hibernate.MappingException: Association references unmapped class: com.ibm.hibernate_a
rticle.Project
at net.sf.hibernate.cfg.Binder.bindCollectionSecondPass(Binder.java:1020)
at net.sf.hibernate.cfg.Binder.bindSetSecondPass(Binder.java:923)
at net.sf.hibernate.cfg.Binder$SetSecondPass.secondPass(Binder.java:1187)
at net.sf.hibernate.cfg.Binder$SecondPass.doSecondPass(Binder.java:1135)
at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:497)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:623)
at Test.main(Test.java:40)




XML Mapping and Java definitions:
---------------------------------------

public class Employee
{
private int employeeId;
private String firstName;
private String lastName;
private String email;
private Employee manager;
private Department department;
private Set projects;
/getter and setters
.....
}


public class Project
{
private int projectId;
private String name;
private Employee employee;
//getter and setters
}


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping.dtd">

<hibernate-mapping>
<class name="com.ibm.hibernate_article.Employee" table="employee">
<id name="employeeId" column="EID">
<generator class="assigned"/>
</id>

<property name="email" column="Email"/>
<property name="firstName" column="FirstName"/>
<property name="lastName" column="LastName"/>

<many-to-one name="department" column="departmentID"/>
<many-to-one name="manager" column="managerEID"/>

<set name="projects" inverse="true" cascade="all" lazy="false">
<key column="EID"/>
<one-to-many class="com.ibm.hibernate_article.Project"/>
</set>

</class>
</hibernate-mapping>





<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping.dtd">

<hibernate-mapping>
<class name="com.ibm.hibernate_article.Project" table="project">
<id name="projectId" column="projectId">
<generator class="assigned"/>
</id>

<property name="name" column="Name"/>
<many-to-one name="employee" column="EID"/>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2003 2:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You're using the wrong DTD.
Code:
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

_________________
Emmanuel


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

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.