-->
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.  [ 1 post ] 
Author Message
 Post subject: mapping error
PostPosted: Wed Jul 28, 2004 5:59 am 
Beginner
Beginner

Joined: Mon Jul 19, 2004 4:55 am
Posts: 34
Hello,
I have 3 classes.
User(id)
Society(users)
Person()
A user could be a society or a person.
So as a society could have many persons, a society could have many users.

classes
Code:
Public class Society extends User
{
   private Collection users;
}

Public class User
{
   private int id;
}

Public class Person extends User
{
   private String Name;
}


User.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
   <class name="bll/User">
      <id name="id">
         <generator class="increment"/>
      </id>
      
      <joined-subclass name="bll.Society" >
                 <key column="id"/>
                 <bag name="users" lazy="true" inverse="true" cascade="all">
            <key column="id"/>
            <one-to-many class=" bll/User"/>
         </bag>
              </joined-subclass>
                      <joined-subclass name=" bll.Person" >
              <key column="id"/>
              <property name="Name"/>
           </joined-subclass>
           
   </class>
</hibernate-mapping>


When I try to save a person, I have an exception :

[code]
net.sf.hibernate.MappingException: No persister for: net.sf.hibernate.collection.Bag at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:344) at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2686) at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2693) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1381) at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114) at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436) at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526) at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452) at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:951) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:779) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738) at


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.