-->
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.  [ 5 posts ] 
Author Message
 Post subject: Schema export: invalid mapping
PostPosted: Wed Apr 27, 2005 2:18 am 
Newbie

Joined: Wed Apr 27, 2005 2:11 am
Posts: 4
I'm getting an exception when I run the schema export tool, but I can't figure out what's wrong with my mapping file. The error generated is not very helpful: "invalid mapping"

Hibernate version: 2.1

Mapping documents:

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

<hibernate-mapping>
<class name="Artist" table="artist">
<id name="id" column="id" type="long" unsaved-value="-1">
<generator class="native"/>
</id>

<property name="name" column="name" type="string" not-null="true"/>
<set name="albums" cascade="all" inverse="true" lazy="true">
<key column="artist_id" not-null="true"/>
<one-to-many class="Record"/>
</set>
</class>

<class name="Record" table="record">
<id name="id" column="id" type="long" unsaved-value="-1">
<generator class="native"/>
</id>
<property name="title" column="title" type="string" not-null="true"/>
<property name="year" column="year" type="string" length="4" not-null="true"/>
<property name="label" column="label" type="string" not-null="true"/>
<property name="limit" column="limit" type="integer" not-null="true"/>
<property name="color" column="color" type="string" not-null="true"/>
<many-to-one name="artist" class="Artist" column="artist_id"/>
</class>
</hibernate-mapping>

Full stack trace of any exception that occurs:

Schema text failed: net.sf.hibernate.MappingException: invalid mapping

Name and version of the database you are using:

Postgres 7.4.7


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 5:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look at the full stack trace and you should see the root cause.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 10:46 pm 
Newbie

Joined: Wed Apr 27, 2005 2:11 am
Posts: 4
Caused by: org.xml.sax.SAXParseException: Attribute "not-null" is not declared for element "key".

This doesn't make any sense. Clearly I have that attribute in the file.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 10:47 pm 
Newbie

Joined: Wed Apr 27, 2005 2:11 am
Posts: 4
By the way, I changed the DTD declaration to point to the 2.0 DTD. That seemed to be part of the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 11:32 pm 
Newbie

Joined: Wed Apr 27, 2005 2:11 am
Posts: 4
Okay, problem solved. The issue here was that the many-to-one element of the Record mapping needed to have a not-null attribute. It was not needed for the key element in Artist.


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