-->
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: MappingException
PostPosted: Sun Jun 20, 2004 7:30 pm 
Newbie

Joined: Sun Jun 20, 2004 7:05 pm
Posts: 2
Hi,
I am working with hibernate for the first time and am just trying to get a first test application working to see how it works. I have used middlegen to create mapping files from the database schema, and changed them only slightly to add joined-class inheritence to two classes, although it seems that even when I use the files generated driectly by middlegen I have this problem. I then used hbm2java to generate java files but the followiong exception is thrown every time I try to buildSessionFactory. I am using mysql 4.1.2 and hibernate 2.1. The Class the exception refers to differs depending on what order I add classes to the configuration. Thank you in advance to anyone who can offer any help.
Joel

Exception:
net.sf.hibernate.MappingException: property mapping has wrong number of columns: com.foothills.fais.hibernate.StudentCategory.mark type: object
at net.sf.hibernate.mapping.PersistentClass.validate(PersistentClass.java:269)
at net.sf.hibernate.mapping.RootClass.validate(RootClass.java:199)
at net.sf.hibernate.cfg.Configuration.validate(Configuration.java:605)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:762)
at main.Test.main(Test.java:52)

Code:
Configuration cfg = new Configuration()
.addClass(com.foothills.fais.hibernate.Person.class)
.addClass(com.foothills.fais.hibernate.Mark.class)
.addClass(com.foothills.fais.hibernate.Address.class)
.addClass(com.foothills.fais.hibernate.EmailAddress.class)
.addClass(com.foothills.fais.hibernate.PhoneNumber.class)
.addClass(com.foothills.fais.hibernate.Track.class)
.addClass(com.foothills.fais.hibernate.Class.class)
.addClass(com.foothills.fais.hibernate.AssignmentDescription.class)
.addClass(com.foothills.fais.hibernate.Course.class)
.addClass(com.foothills.fais.hibernate.Term.class)
.addClass(com.foothills.fais.hibernate.EnrolledStudent.class)
.addClass(com.foothills.fais.hibernate.StudentCategory.class)
.addClass(com.foothills.fais.hibernate.TermWeight.class)
.addClass(com.foothills.fais.hibernate.CategoryDescription.class)
.addClass(com.foothills.fais.hibernate.CategoryWeight.class);

StuentCategory.hbm.xml:
<?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>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="com.foothills.fais.hibernate.StudentCategory"
table="student_categories"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="student_categories"
</meta>

<id
name="studentCategoryId"
type="java.lang.Object"
column="Student_Category_Id"
>
<meta attribute="field-description">
@hibernate.id
generator-class="native"
type="java.lang.Object"
column="Student_Category_Id"

</meta>
<generator class="native" />
</id>

<property
name="mark"
type="java.lang.Float"
column="mark"
length="12"
>
<meta attribute="field-description">
@hibernate.property
column="mark"
length="12"
</meta>
</property>
<property
name="comments"
type="java.lang.String"
column="comments"
length="65535"
>
<meta attribute="field-description">
@hibernate.property
column="comments"
length="65535"
</meta>
</property>

<!-- associations -->
<!-- bi-directional many-to-one association to Term -->
<many-to-one
name="term"
class="com.foothills.fais.hibernate.Term"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="term_id"
</meta>
<column name="term_id" />
</many-to-one>
<!-- bi-directional many-to-one association to CategoryDescription -->
<many-to-one
name="categoryDescription"
class="com.foothills.fais.hibernate.CategoryDescription"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="category_id"
</meta>
<column name="category_id" />
</many-to-one>
<!-- bi-directional many-to-one association to Student -->
<many-to-one
name="student"
class="com.foothills.fais.hibernate.Student"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="student_id"
</meta>
<column name="student_id" />
</many-to-one>
<!-- bi-directional many-to-one association to Class -->
<many-to-one
name="clazz"
class="com.foothills.fais.hibernate.Class"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="class_id"
</meta>
<column name="class_id" />
</many-to-one>

</class>
</hibernate-mapping>


Table Student_Categories:
CREATE TABLE IF NOT EXISTS Student_Categories(
Student_Category_Id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
student_id INT UNSIGNED NOT NULL,
class_id SMALLINT UNSIGNED NOT NULL,
category_id SMALLINT UNSIGNED NOT NULL,
term_id SMALLINT UNSIGNED,
mark FLOAT UNSIGNED,
comments TEXT,
INDEX student_index (student_id),
INDEX class_index (class_id),
INDEX category_index (category_id),
INDEX term_index (term_id),
FOREIGN KEY student_reference (student_id) REFERENCES Students(student_id) ON DELETE CASCADE,
FOREIGN KEY class_reference (class_id) REFERENCES Classes(class_id) ON DELETE CASCADE,
FOREIGN KEY category_reference (category_id) REFERENCES Category_Descriptions(category_id) ON DELETE CASCADE,
FOREIGN KEY term_reference (term_id) REFERENCES Terms(term_id) ON DELETE CASCADE
) ENGINE = INNODB;


Top
 Profile  
 
 Post subject: Got It...
PostPosted: Mon Jun 21, 2004 4:08 am 
Newbie

Joined: Sun Jun 20, 2004 7:05 pm
Posts: 2
Well, it took a while... A long while nad I feel pretty ridiculous once all is said and done. I was missing a file (aoppliace.jar or something) in my classpsath for one day of work :-( So for anyone else that has this problem I hope you find this and it saves you alot of time, or perhaps you will just be smart enough to fix the problem way faster anyways. Thank you anyone who looked at this post.

Sincerely JJ


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.