-->
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.  [ 3 posts ] 
Author Message
 Post subject: Code Generation error in hbm2java for inheritance
PostPosted: Fri Oct 01, 2004 12:07 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
Hibernate version:
2.1.6

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

<hibernate-mapping>

  <!-- TripwireIncident Object-->
  <class name="com.waypoint.rs.incident.tripwire.TripwireIncidentObject"
    table="RS_TW_INCDT_OBJECT" discriminator-value="OBJECT">
   
    <meta attribute="class-description">
      Represents a tripwire incident object
 
      @author Sameet Nasnodkar
    </meta>
   
    <id name="id" type="long" column="ID">
      <generator class="native"/>
    </id>

   <property name="name" type="string">
      <meta attribute="use-in-tostring">true</meta>
      <column name="NAME" not-null="true"/>
   </property>

   <discriminator column="OBJECT_TYPE" type="string"/>
   
   <subclass name="com.waypoint.rs.incident.tripwire.AddedTripwireIncidentObject"
      discriminator-value="ADDED"/>

   <subclass name="com.waypoint.rs.incident.tripwire.ChangedTripwireIncidentObject"
      discriminator-value="CHANGED"/>

   <subclass name="com.waypoint.rs.incident.tripwire.RemovedTripwireIncidentObject"
      discriminator-value="REMOVED"/>

   <!--many-to-one name="incident" class="com.waypoint.rs.incident.tripwire.TripwireIncident"
      column="INCIDENT_ID" not-null="true"/-->
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
Code:
[hbm2java] (hbm2java.CodeGenerator              48  ) Error parsing XML: file:/
C:/work/waypoint/WaypointRS/dbproject/src/com/waypoint/rs/incident/tripwire/Trip
wireIncidentObject.hbm.xml(39)
[hbm2java] org.xml.sax.SAXParseException: The content of element type "class" m
ust match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|t
imestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|
set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))".
[hbm2java]     at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseExce
ption(Unknown Source)
[hbm2java]     at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Sour
ce)
[hbm2java]     at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown S
ource)
[hbm2java]     at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown S
ource)
[hbm2java]     at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(U
nknown Source)
[hbm2java]     at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown
Source)
[hbm2java]     at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElemen
t(Unknown Source)
[hbm2java]     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragmen
tContentDispatcher.dispatch(Unknown Source)
[hbm2java]     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDoc
ument(Unknown Source)
[hbm2java]     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown So
urce)
[hbm2java]     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown So
urce)
[hbm2java]     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
[hbm2java]     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Sou
rce)
[hbm2java]     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)
[hbm2java]     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:724)
[hbm2java]     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:703)
[hbm2java]     at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerat
or.java:100)
[hbm2java]     at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2J
avaTask.java:145)
[hbm2java]     at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaT
ask.java:95)
[hbm2java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:269)
[hbm2java]     at org.apache.tools.ant.Task.perform(Task.java:364)
[hbm2java]     at org.apache.tools.ant.Target.execute(Target.java:301)
[hbm2java]     at org.apache.tools.ant.Target.performTasks(Target.java:328)
[hbm2java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1215)

[hbm2java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1063
)
[hbm2java]     at org.apache.tools.ant.Main.runBuild(Main.java:632)
[hbm2java]     at org.apache.tools.ant.Main.startAnt(Main.java:183)
[hbm2java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
[hbm2java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)

Name and version of the database you are using:

The generated SQL (show_sql=true):
N/A

Debug level Hibernate log excerpt:
N/A


I am trying to generate code using the table per class hierarchy mechanism for inheratance. I know there is something small that I am missing. Could anyone please point it out to me?

_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 01, 2004 12:12 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
Just wanted to add If I take out the subclassing portions including the discriminator then everything generates fine.

_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 01, 2004 3:21 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
I got the error, I had to put the
Code:
discriminator
tag before the
Code:
property
tag as per the dtd. It is a silly mistake but not very apparent at first.

_________________
Thanks
Sameet


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.