-->
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: Error : Error parsing XML: XML InputStream(20) Attribute &qu
PostPosted: Thu Aug 04, 2005 6:19 am 
Newbie

Joined: Thu Aug 04, 2005 5:57 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

Mapping documents:
<?xml version="1.0"?>
<!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.hsql.Customer" table="Customer">
<!-- works for schemaExport -->

<id name="id" type="long">
<column name="id" sql-type="int" />
<generator class="increment"/>
</id>


<!-- works for schemaExport -->
<property name="firstname" type="String">
<column name="firstname" sql-type="varchar" />
</property>

<property name="lastname" type="String">
<column name="lastname" sql-type="varchar" />
</property>
<property name="age" type="String">
<column name="age" sql-type="int" />
</property>

<property name="gender" type="String">
<column name="gender" sql-type="char(1)" />
</property>

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Transaction tx = session.beginTransaction();

Customer customer=new Customer();
customer.setFirstName("John");
customer.setLastName("Doe");
customer.setGender('M');
customer.setAge(33);

session.save(customer);

tx.commit();


Full stack trace of any exception that occurs:
[java] 15:33:42,937 ERROR XMLHelper:59 - Error parsing XML: XML InputStream(20) Attribute "column" must be declared for element type "one-to-many".
[java] Initial SessionFactory creation failed.org.hibernate.MappingException: Error reading resource: CustomerAddress.hbm.xml
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at com.hsql.HibernateUtil.<clinit>(Unknown Source)
[java] at com.hsql.EventManager.createAndStoreCustomer(Unknown Source)
[java] at com.hsql.EventManager.main(Unknown Source)
[java] Caused by: org.hibernate.MappingException: Error reading resource: CustomerAddress.hbm.xml
[java] at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
[java] at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
[java] at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
[java] ... 3 more
[java] Caused by: org.hibernate.MappingException: invalid mapping
[java] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
[java] at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
[java] ... 9 more
[java] Caused by: org.xml.sax.SAXParseException: Attribute "column" must be declared for element type "one-to-many".
[java] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
[java] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
[java] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
[java] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
[java] at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(XMLDTDValidator.java:1306)
[java] at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1971)
[java] at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:816)
[java] at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
[java] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
[java] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
[java] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
[java] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
[java] at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
[java] at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
[java] at org.dom4j.io.SAXReader.read(SAXReader.java:465)
[java] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
[java] ... 10 more

BUILD SUCCESSFUL
Total time: 3 seconds


Name and version of the database you are using:
hsqldb
The generated SQL (show_sql=true):
Generated sql statement for table creation
drop table Customer if exists;
create table Customer (
id int not null,
firstname varchar,
lastname varchar,
age int,
gender char(1),
primary key (id)
);

No Sql statement is generated for the insert statement.
Debug level Hibernate log excerpt:
How to get the hibernate log excerpt?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 6:48 am 
Newbie

Joined: Thu Aug 04, 2005 5:57 am
Posts: 2
hibernate.cfg file is missing. So there is no mapping. This is the cause.


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.