-->
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: Problem parsing *.hbm.xml
PostPosted: Thu Sep 09, 2004 1:13 am 
Newbie

Joined: Sat Sep 04, 2004 12:59 pm
Posts: 1
I am having trouble getting started with hibernate. I keep getting errors with parsing my hbm.xml files and i can't figure out why. Any help would be greatly appreciated. I have been banging my head for a couple of days and i cant get any farther.

thanks


Hibernate version: 2.1

Mapping documents: hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="connection.pool_size">1</property>
<property name="show_sql">true</property>
<property name="connection.datasource">java:comp/env/jdbc/pelican</property>
<property name="dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property>
<mapping resource="com/trukn/pelican/model/Property.hbm.xml"/>
<mapping resource="com/trukn/pelican/model/PropertyType.hbm.xml"/>
<mapping resource="com/trukn/pelican/model/User.hbm.xml"/>
<mapping resource="com/trukn/pelican/model/Region.hbm.xml"/>
<mapping resource="com/trukn/pelican/model/BinaryFile.hbm.xml"/>
</session-factory>

</hibernate-configuration>


Property.hbm.xml

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


<hibernate-mapping package="com.trukn.pelican.model" default-cascade="none">

<class name="Property"
table="PROPERTY" lazy="true">

<!-- Common id property. -->
<id name="propertyId"
type="long"
column="PROPERTY_ID"
unsaved-value="null" cascade="none">
<generator class="native"/>
</id>

<!-- A versioned entity.
<version name="version"
column="VERSION"
type="int"/>-->

<!-- Name of the item is immutable. -->
<property name="propertyTitle"
type="string"
column="PROPERTY_TITLE"
length="255"
not-null="true"
update="false"
cascade="none"/>

<!-- Type of Property -->
<property name="propertyType"
type="PropertyType"
column="PROPERTY_TYPE_ID"
cascade="none"
not-null="false"
outer-join="false"
foreign-key="FK1_PROPERTY_PROPERTY_TYPE_ID"/>

<!-- Address line 1 -->
<property name="address1"
type="string"
column="ADDRESS1"
length="255"
cascade="none"/>

<!-- Address line 2 -->
<property name="address2"
type="string"
column="ADDRESS2"
length="255"
cascade="none"/>

<!-- City -->
<property name="city"
type="string"
column="CITY"
length="255"
cascade="none"/>

<!-- STATE -->
<property name="state"
type="string"
column="STATE"
length="2"
cascade="none"/>

<!-- Zip Code -->
<property name="zip"
type="string"
column="ZIP"
length="16"
cascade="none"/>

<!-- The Region the property was in -->
<property name="region"
type="Region"
column="REGION_ID"
cascade="none"
not-null="false"
outer-join="false"
foreign-key="FK1_PROPERTY_REGION_ID"/>

<!-- COUNTY -->
<property name="county"
type="string"
column="COUNTY"
length="255"
cascade="none"/>

<!-- Total Price of property -->
<property name="totalPrice"
type="float"
column="TOTAL_PRICE"
cascade="none"/>

<!-- The price per acre of the property -->
<property name="pricePerAcre"
type="float"
column="PRICE_PER_ACRE"
not-null="true"
cascade="none"/>

<!-- Zoning of Property -->
<property name="zoning"
type="string"
column="ZONING"
length="255"
cascade="none"/>

<!-- If the property can be broken up into lots -->
<property name="lots"
type="boolean"
column="LOTS"
cascade="none"/>
<!-- the acreage of the property that is available -->
<property name="acerage"
type="float"
column="acerage"
not-null="true"
cascade="none"/>

<!-- if the property is a lease price -->
<property name="lease"
type="boolean"
column="lease"
cascade="none"/>

<!-- Limit item description to 4000 characters, Oracle. -->
<property name="description"
type="string"
column="DESCRIPTION"
length="4000"
not-null="true"
cascade="none"/>



<!-- We can't change the creation time, so map it with update="false". -->
<property name="created"
column="CREATED_DATE"
type="timestamp"
update="false"
not-null="true"
cascade="none"/>

<!-- Status of the property -->
<property name="status"
type="string"
column="STATUS"
length="20"
not-null="true"
cascade="none"/>

<!-- We can't change the startDate. -->
<property name="updated"
column="UPDATED_DATE"
type="java.util.Date"
update="true"
not-null="true"
cascade="none"/>

<!-- We can't change the startDate. -->
<property name="start"
column="START_DATE"
type="java.util.Date"
update="false"
not-null="true"
cascade="none"/>

<!-- We can't change the endDate. -->
<property name="closed"
column="CLOSED_DATE"
type="java.util.Date"
update="false"
cascade="none"/>

<!-- Simple property. -->
<property name="approvalDatetime"
column="APPROVAL_DATETIME"
type="java.util.Date"
not-null="false"
cascade="none"/>

<!-- PDF OF PROPERTY LISTING -->
<many-to-one name="pdf"
class="BinaryFile"
cascade="none"
column="PDF_FILE_ID"
not-null="true"
outer-join="false"
foreign-key="FK3_PDF_FILE_ID"/>

</class>



</hibernate-mapping>


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



Name and version of the database you are using: postgres 7.3

Full stack trace of any exception that occurs:

01:08:54,720 INFO Configuration: configuring from resource: /hibernate.cfg.xml
01:08:54,721 INFO Configuration: Configuration resource: /hibernate.cfg.xml
01:08:55,274 INFO Configuration: Mapping resource: com/trukn/pelican/model/Property.hbm.xml
01:08:55,428 ERROR XMLHelper: Error parsing XML: XML InputStream(15) Attribute "cascade" must be declared for element type "id".
01:08:55,431 ERROR XMLHelper: Error parsing XML: XML InputStream(31) Attribute "cascade" must be declared for element type "property".
01:08:55,433 ERROR XMLHelper: Error parsing XML: XML InputStream(40) Attribute "cascade" must be declared for element type "property".
01:08:55,442 ERROR XMLHelper: Error parsing XML: XML InputStream(40) Attribute "outer-join" must be declared for element type "property".
01:08:55,444 ERROR XMLHelper: Error parsing XML: XML InputStream(40) Attribute "foreign-key" must be declared for element type "property".
01:08:55,445 ERROR XMLHelper: Error parsing XML: XML InputStream(47) Attribute "cascade" must be declared for element type "property".
01:08:55,447 ERROR XMLHelper: Error parsing XML: XML InputStream(54) Attribute "cascade" must be declared for element type "property".
01:08:55,450 ERROR XMLHelper: Error parsing XML: XML InputStream(61) Attribute "cascade" must be declared for element type "property".
01:08:55,451 ERROR XMLHelper: Error parsing XML: XML InputStream(68) Attribute "cascade" must be declared for element type "property".
01:08:55,453 ERROR XMLHelper: Error parsing XML: XML InputStream(75) Attribute "cascade" must be declared for element type "property".
01:08:55,455 ERROR XMLHelper: Error parsing XML: XML InputStream(84) Attribute "cascade" must be declared for element type "property".
01:08:55,474 ERROR XMLHelper: Error parsing XML: XML InputStream(84) Attribute "outer-join" must be declared for element type "property".
01:08:55,477 ERROR XMLHelper: Error parsing XML: XML InputStream(84) Attribute "foreign-key" must be declared for element type "property".
01:08:55,479 ERROR XMLHelper: Error parsing XML: XML InputStream(91) Attribute "cascade" must be declared for element type "property".
01:08:55,481 ERROR XMLHelper: Error parsing XML: XML InputStream(97) Attribute "cascade" must be declared for element type "property".
01:08:55,483 ERROR XMLHelper: Error parsing XML: XML InputStream(104) Attribute "cascade" must be declared for element type "property".
01:08:55,485 ERROR XMLHelper: Error parsing XML: XML InputStream(111) Attribute "cascade" must be declared for element type "property".
01:08:55,489 ERROR XMLHelper: Error parsing XML: XML InputStream(117) Attribute "cascade" must be declared for element type "property".
01:08:55,490 ERROR XMLHelper: Error parsing XML: XML InputStream(123) Attribute "cascade" must be declared for element type "property".
01:08:55,492 ERROR XMLHelper: Error parsing XML: XML InputStream(129) Attribute "cascade" must be declared for element type "property".
01:08:55,493 ERROR XMLHelper: Error parsing XML: XML InputStream(137) Attribute "cascade" must be declared for element type "property".
01:08:55,495 ERROR XMLHelper: Error parsing XML: XML InputStream(163) Attribute "cascade" must be declared for element type "property".
01:08:55,497 ERROR XMLHelper: Error parsing XML: XML InputStream(171) Attribute "cascade" must be declared for element type "property".
01:08:55,499 ERROR XMLHelper: Error parsing XML: XML InputStream(179) Attribute "cascade" must be declared for element type "property".
01:08:55,501 ERROR XMLHelper: Error parsing XML: XML InputStream(187) Attribute "cascade" must be declared for element type "property".
01:08:55,503 ERROR XMLHelper: Error parsing XML: XML InputStream(194) Attribute "cascade" must be declared for element type "property".
01:08:55,505 ERROR XMLHelper: Error parsing XML: XML InputStream(201) Attribute "cascade" must be declared for element type "property".
01:08:55,597 ERROR HibernateUtil: Initial SessionFactory creation failed: Error reading resource: com/trukn/pelican/model/Property.hbm.xml
net.sf.hibernate.MappingException: Error reading resource: com/trukn/pelican/model/Property.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1013)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:969)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:883)
at com.trukn.pelican.HibernateUtil.<clinit>(HibernateUtil.java:29)
at com.trukn.pelican.actions.BuildSchema.execute(BuildSchema.java:34)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1158)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:552)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
... 41 more
Caused by: org.xml.sax.SAXParseException: Attribute "cascade" must be declared for element type "id".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:286)
... 42 more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 2:07 am 
Regular
Regular

Joined: Thu Aug 05, 2004 2:27 am
Posts: 54
Location: South Africa
your problems are "cascade=", outer-join and foreign key, you have these in several places where they don't belong. foreign-key is not in the DTD at all, you define a parent child relationship very differently.
so start by understanding what they do, amongst other basic things, check the faq, read the docs, only enough to get started, you'll learn as you go, and get rid of everything in your mapping that you don't need, add only what you actually need, much easier to work with then.


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.