-->
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.  [ 7 posts ] 
Author Message
 Post subject: Parsing error for the hibernate cfg.xml
PostPosted: Mon Jun 28, 2004 11:09 pm 
Newbie

Joined: Mon Oct 27, 2003 8:15 pm
Posts: 10
Location: Birmingham, AL
I'm getting an error on parsing my hibernate.cfg.xml file:
The error occurs in Configuration.java
Code:
         List errors = new ArrayList();
         org.dom4j.Document doc = XMLHelper.createSAXReader("XML InputStream", errors).read( new InputSource(xmlInputStream) );
         if ( errors.size()!=0 ) throw new MappingException( "invalid mapping", (Throwable) errors.get(0) );


The read produces a SAXParseException
detailMessage= "Attribute "not-null" must be declared for element type "id"."


I'm using hibernate2.1.3 with the following configuration:
Code:
<?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 name="OldFMSF">
      <!-- local connection properties -->
      <property name="hibernate.connection.url">
         jdbc:hsqldb://isis:11476
      </property>
      <property name="hibernate.connection.driver_class" />
      <property name="hibernate.connection.username">sa</property>
      <property name="hibernate.connection.password" />
      <!-- property name="hibernate.connection.pool_size"></property -->
      <!-- dialect for HypersonicSQL -->
      <property name="dialect">
         net.sf.hibernate.dialect.HSQLDialect
      </property>
      <property name="hibernate.show_sql">false</property>
      <property name="hibernate.use_outer_join">true</property>
      <property name="hibernate.transaction.factory_class">
         net.sf.hibernate.transaction.JTATransactionFactory
      </property>
      <property name="jta.UserTransaction">
         java:comp/UserTransaction
      </property>
      <mapping resource="CurrencyCode.hbm" />
   </session-factory>
</hibernate-configuration>


Code:
<?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="net.sf.freemercator.transfer">
   <class
      name="CurrencyCode"
      proxy="IF_CurrencyCode"
      table="CURRENCY_CODE"
   >
      <id column="CURRENCY_CODE_ID" name="currencyCodeId" type="java.lang.Integer" not-null="true" >
         <generator class="native"/>
      </id>
      
      <property
         column="CURRENCY_CODE"
         name="currencyCode"
         not-null="false"
         type="integer"
       />
      <property
         column="VARIANT"
         length="2"
         name="variant"
         not-null="false"
         type="string"
       />
      <property
         column="LANGUAGE"
         length="2"
         name="language"
         not-null="false"
         type="string"
       />
      <property
         column="CURRENCY_DESC"
         length="50"
         name="currencyDesc"
         not-null="false"
         type="string"
       />
   </class>
</hibernate-mapping>


This code was generated by HibernateSynchronizer but it looks good to me. Any thoughts as to where I messed up? I have only the one hibernate2.jar in my classpath.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 2:21 am 
Newbie

Joined: Mon Oct 27, 2003 8:15 pm
Posts: 10
Location: Birmingham, AL
I upgraded to 2.1.4 and the behavior continues.


Top
 Profile  
 
 Post subject: Upgrade and remove constraint
PostPosted: Tue Jun 29, 2004 2:32 am 
Newbie

Joined: Mon Oct 27, 2003 8:15 pm
Posts: 10
Location: Birmingham, AL
Removing the non-null attribute and upgrading to 2.1.4 seems to have solved this section of my problems.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 8:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
<id not-null=...> is not allowed as per the DTD

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 10:22 am 
Newbie

Joined: Mon Oct 27, 2003 8:15 pm
Posts: 10
Location: Birmingham, AL
I was misreading the error message. But when I removed the not-null before upgrading, it still didn't parse. Is that a version-related issue?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 12:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No, it works from the very early ages

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 1:15 pm 
Newbie

Joined: Mon Oct 27, 2003 8:15 pm
Posts: 10
Location: Birmingham, AL
I figured out what happened.
The table didn't have an <id> defined from HibernateSynchronizer because it didn't/doesn't have a Primary Key! (not my design...)

So when I changed from a property to an id, I left in the "not-null".

Still doesn't explain why it failed when I removed the not-null altogether... :(


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