-->
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: Inheritance mapping - Table per subclass
PostPosted: Sat Nov 29, 2008 5:46 am 
Beginner
Beginner

Joined: Sat Oct 18, 2008 10:25 am
Posts: 30
Hi,

I want to map a simple class hierarchy that consists of two classes at the moment: Person and Lodger. Lodger is inherited from Person.

I want to use table per subclass with mapping files. Do I need a own mapping file for the class Lodger? My mapping file for Person looks like this:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false" auto-import="false">
   <class name="de.waldhausweg7.model.Person" table="Person">
      <id name="personId" type="int">
         <generator class="increment" />
      </id>
      <property name="firstName" column="firstName" />
      <property name="surName" column="surName" />
      <property name="street" column="street" />
      <property name="extraAddressLine" column="extraAddressLine" />
      <property name="phone" column="phone" />
      <property name="mobile" column="mobile" />
      <property name="fax" column="fax" />
      <property name="email" column="email" />
      <property name="comment" column="comment" />
      
      <!-- 1:n-Beziehung zu Ort -->
      <many-to-one name="city" column="cityId" class="de.waldhausweg7.model.City" />
      
      <!-- n:m-Beziehung zu Kategorie -->
      <set name="categories" table="person_category" lazy="false">
         <key column="personId" />
         <many-to-many class="de.waldhausweg7.model.Category" column="categoryId" />
      </set>
      
      <!-- Beziehung zu Unterklasse Lodger -->
      <joined-subclass name="de.waldhausweg7.model.Lodger" table="lodger">
         <key column="personId" />
         <property name="gender" column="gender" />
      </joined-subclass>
   </class>
</hibernate-mapping>


I created a mapping file for Lodger:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false" auto-import="false">
   <class name="de.waldhausweg7.model.Category" table="Category">
      <id name="lodgerId" type="int">
         <generator class="foreign" />
      </id>
      <property name="gender" column="gender" />
   </class>
</hibernate-mapping>


The lodger-Table contains a field called lodgerId as primary key.

But it does not work.


This is the error (I use Hibernate with IceFaces):

javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: Could not initialize class de.waldhausweg7.utils.HibernateUtil
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:190)
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
javax.faces.component.UIData.getValue(UIData.java:547)
com.icesoft.faces.component.panelseries.UISeries.getDataModel(UISeries.java:310)
com.icesoft.faces.component.panelseries.UISeries.processCurrentRowData(UISeries.java:138)
com.icesoft.faces.component.panelseries.UISeries.setRowIndex(UISeries.java:130)
com.icesoft.faces.component.ext.renderkit.TableRenderer.renderFacet(TableRenderer.java:140)
com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.encodeBegin(TableRenderer.java:115)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:703)
javax.faces.component.UIData.encodeBegin(UIData.java:701)
com.icesoft.faces.component.panelseries.UISeries.encodeBegin(UISeries.java:251)
javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:613)
javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:565)
com.icesoft.faces.component.DataTableTag.doEndTag(DataTableTag.java:732)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:237)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.parse(Parser.java:157)
com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:508)
com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:161)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:268)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:25)
com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:161)
com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:30)
com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:48)
com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:139)
com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:82)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)



Can someone help me?


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.