-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem mapping many to many in inheritance relationship
PostPosted: Fri Jan 11, 2008 3:52 pm 
Newbie

Joined: Fri Oct 27, 2006 2:28 pm
Posts: 14
Please see where I got it wrong. The error is:
Could not determine type for: Person, for columns: [org.hibernate.mapping.Column(TEACHER_ID)]

Hibernate version: 3.1.3

Mapping documents:
Code:
   <class name="Book" schema="AAAA" table="BOOK">
      <id name="id" column="ID" type="java.lang.Long">
            <generator class="sequence">
                <param name="sequence">s_global_id</param>
            </generator>
        </id>
   <property name="title" type="java.lang.String" column="TITLE" />
   </class>

    <class name="Person" schema="AAAA" table="PERSON">
        <id name="id" column="ID" type="java.lang.Long">
            <generator class="sequence">
                <param name="sequence">s_global_id</param>
            </generator>
        </id>
        <joined-subclass name="Teacher"  schema="AAAA" table="TEACHER">
            <key column="ID"/>
            <list name="books" table="TEACHER_BOOK" fetch="select" cascade="all">
                <key column="TEACHER_ID" />
                <list-index column="INDX" base="0"/>
                <many-to-many  column="BOOK_ID" class="Book" fetch="select" />
            </list>
        </joined-subclass>
    </class>


Full stack trace of any exception that occurs:
Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: Person, for columns: [org.hibernate.mapping.Column(TEACHER_ID)]
Caused by: org.hibernate.MappingException: Could not determine type for:Person, for columns: [org.hibernate.mapping.Column(TEACHER_ID)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)

Name and version of the database you are using:

MySql Ver 14.12 Distrib 5.0.45


Code:


class Book {
   Long id;
   
   String title;

   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public String getTitle() {
      return title;
   }

   public void setTitle(String title) {
      this.title = title;
   }
}

class Person {
   Long id;
   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }
}

class Teacher extends Person {
   List<Book> books;
   public List<Book> getBooks() {
      return books;
   }

   public void setBooks(List<Book> books) {
      this.books = books;
   }
}



Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 1:00 pm 
Newbie

Joined: Fri Oct 27, 2006 2:28 pm
Posts: 14
I saw an option: foreign-key="foreign_key_name"
I wonder if adding this attribute would solve the problem. What is the value of the foreign_key_name? Is it the foreign key name of the TEACHER table (in the database), or is it the name of class "Teacher" (to say that TEACHER_ID is the foreign key of Teacher entity).
Would someone please shed some light on this? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 4:32 pm 
Newbie

Joined: Fri Oct 27, 2006 2:28 pm
Posts: 14
I got it to work. The error turns out to be some other configuration totally unrelated to this.


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