-->
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: Vererbung aus einer Klasse eines Frameworks
PostPosted: Wed Nov 21, 2007 11:47 am 
Newbie

Joined: Wed Nov 21, 2007 10:33 am
Posts: 1
Hallo!

Ich habe folgendes Problem:

Eine zu persistierende Klasse enthält eine Liste mit Objekten einer Superklasse eines Frameworks. In dieser Liste sollen später verschiedene Subklassen mit persistiert werden. Nun stellt sich mir die Frage wie ich das mappen soll.

Muss ich eine mapping-file für die Superklasse schreiben, welche sämtliche Unterkassen bis zu der zu persistierenden Subklasse enthält?
Dabei müsste ich ja die Superklasse des Frameworks modifizieren damit sie eine ID erhält.

Oder gibt es da einen ganz anderen Weg den ich nur noch nicht kenne?

Zum besseren Verständnis die Klassenhierachie der zu persistierenden Subklassen:
java.lang.Object
javax.faces.component.UIComponent
javax.faces.component.UIComponentBase
javax.faces.component.UIOutput
org.richfaces.component.UIMenuGroup
org.richfaces.component.html.HtmlMenuGroup

java.lang.Object
javax.faces.component.UIComponent
javax.faces.component.UIComponentBase
javax.faces.component.UICommand
org.ajax4jsf.component.AjaxActionComponent
org.richfaces.component.UIMenuItem
org.richfaces.component.html.HtmlMenuItem


Mein bisheriger Code sieht so aus, funktioniert natürlich nicht, weil UIComponent kein Attribut "uIComponentId" hat:

Code:
public class DropDownMenu
   private long dropDownMenuId;
   private boolean visible;
   private int rank;
   private String icon;
   private List<UIComponent> children;
   //Konstruktor, Getter und Setter

// Die Superklasse aus dem Framework
public class UIComponent

// Zu persistierende Subklassen:
public class MenuGroup extends HtmlMenuGroup {
   private long menuGroupId;
   private boolean visible;
   private int rank;
   private String icon;
   //Konstruktor, Getter und Setter

public class MenuItem extends HtmlMenuItem {
   private long menuItemId;
   private boolean visible;
   private int rank;
   private int toolBarGroup;
   private String icon;
   //Konstruktor, Getter und Setter


Die mapping-files: (Das mit den ganzen Subklassen sieht etwas seltsam aus...)
Code:
<hibernate-mapping package="crm.jsf.ui.menu">
  <class name="DropDownMenu" table="_dropDownMenu">
        <id name="dropDownMenuId" column="id">
           <generator class="native"/>
        </id>     
        <property name="visible" type="yes_no"/>     
        <property name="rank"/>   
        <property name="icon"/>       
        <list name="children" cascade="save-update">
   <key column="dropDownMenu_Id" not-null="true"/>
   <list-index column="children_index"/>
   <one-to-many class="crm.jsf.ui.menu.UIComponent"/>
        </list>       
  </class>
</hibernate-mapping>

<hibernate-mapping package="javax.faces.component">
   <class name="UIComponent" table="_uIComponent">
      <id name="uIComponentId" column="id">
           <generator class="native"/>
      </id>
   <discriminator column="uIComponent_typ" type="string"/>
   <subclass name="UIComponentBase" discriminator-value="Base">
   <subclass name="UIOutput" discriminator-value="output">
   <subclass name="UIMenuGroup" discriminator-value="group">
   <subclass name="html.HtmlMenuGroup" discriminator-value="htmlGroup">
   <subclass name="MenuGroup" discriminator-value="menuGroup">
   <property name="visible" type="yes_no"/>
   <property name="rank"/>
   <property name="icon"/>       
   <list name="children" cascade="save-update">
       <key column="dropDownMenu_Id" not-null="true"/>
       <list-index column="children_index"/>
       <one-to-many class="model.contact.contactobjects.UIComponent"/>
   </list>
   </subclass>
   </subclass>
   </subclass>
   </subclass>
   <subclass name="UICommand" discriminator-value="command">
   <subclass
      name="org.ajax4jsf.component.AjaxActionComponent" discriminator-
      value="ajaxCommand">
   <subclass name="org.richfaces.component.UIMenuItem" discriminator-value="item">
   <subclass name="org.richfaces.component.html.HtmlMenuItem" 
      discriminator-value="htmpItem">
   <subclass name="MenuItem" discriminator-value="menuItem">
          <property name="visible" type="yes_no"/>
          <property name="rank"/>
          <property name="icon"/>
          <property name="toolBarGroup"/>
          <property name="expression"/>
          <property name="expectedReturnType"/>
          <array name="expectedParamTypes"
                     table="_menuItem_expectedParamTypes">
                  <key column="menuItemMenuId"/>
                  <list-index column="expectedParamType_index"/>
                  <element column="expectedParamType"
                                 type="java.lang.string"/>
          </array>
    </subclass>
    </subclass>
    </subclass>
    </subclass>
    </subclass>
    </subclass>               
</class>   
</hibernate-mapping>


Es wäre echt super wenn einer da eine Idee hätte. In dem Framework rumzuwerkeln fände ich irgendwie nicht so gut.


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.