tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
3
ZUGRIFFE
4558
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    mahosand mahosand ist offline Mitglied
    Registriert seit
    Oct 2004
    Beiträge
    15
    Guten abend,

    ich habe folgendes Problem, un zwar beim Zugriff auf Properties aus einem Set wird eine Exception geworfen.

    Ein geküztes Programm-Code möchte ich hier unten vorstellen.

    Erste Klasse : Patient

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    
     
       [COLOR=black][FONT=&quot]// Generated 20.12.2006 [/FONT][/COLOR][COLOR=black][FONT=&quot]20:30:40[/FONT][/COLOR][COLOR=black][FONT=&quot] by Hibernate Tools 3.1.0.beta5[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]//imports …[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]/**[/FONT][/COLOR]
      [COLOR=black][FONT=&quot] * Patient generated by hbm2java[/FONT][/COLOR]
      [COLOR=black][FONT=&quot] */[/FONT][/COLOR]
      [COLOR=black][FONT=&quot][B]public class [/B]Patient implements java.io.Serializable {[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      // Fields    [/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]private int [/B]patientId;[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]private[/B] [B]Set[/B]<Feedback> feedbacks = new       [/FONT][/COLOR][COLOR=black][FONT=&quot]
    [/FONT][/COLOR]
    [COLOR=black][FONT=&quot]                            [B]HashSet[/B][/FONT][/COLOR][COLOR=black][FONT=&quot]<Feedback>(0);[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]private Set[/B]<Chemotest> chemotests = new 
    [/FONT][/COLOR]
    [COLOR=black][FONT=&quot]                             [B]HashSet[/B]<Chemotest>(0);[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      // Constructors[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      /** default constructor */[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]     [B]public[/B] Patient() {[/FONT][/COLOR]
          [COLOR=black][FONT=&quot]}[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]// Property accessors[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]     [B]public int[/B] getPatientId() {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            [B]return[/B] this.patientId;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      }[/FONT][/COLOR]
    [COLOR=black][FONT=&quot]      ...
     
    [/FONT][/COLOR]   [COLOR=black][FONT=&quot]     [B]public Set[/B]<Feedback> getFeedbacks() {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            [B]return[/B] this.feedbacks;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      }[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]public void[/B] setFeedbacks(Set<Feedback> feedbacks) {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            this.feedbacks = feedbacks;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      }[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]public Set[/B]<Chemotest> getChemotests() {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            return this.chemotests;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      }[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]public void [/B]setChemotests(Set<Chemotest> chemotests) {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]this.chemotests = chemotests;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      }[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]}[/FONT][/COLOR]
    Die zweite Klasse : Feedback

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    
     
     
      
    [B][COLOR=black][FONT=&quot]public[/FONT][/COLOR][/B][COLOR=black][FONT=&quot] [B]class[/B] Feedback [B]implements[/B] java.io.Serializable {[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]// Fields    [/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]private[/B] [B]int[/B]  feedbackId;[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]private[/B] Patient   patient;[/FONT][/COLOR]
      
            [B][COLOR=black][FONT=&quot]private[/FONT][/COLOR][/B][COLOR=black][FONT=&quot] String   feedbackText;[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]private[/B] [B]byte[/B] type;[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      [B]private[/B] Date date;[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      // Constructors[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      /** default constructor */[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      [B]public[/B] Feedback() {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      }[/FONT][/COLOR]
      
     
      [COLOR=black][FONT=&quot]      // Property accessors[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      [B]public[/B] [B]int[/B] getFeedbackId() {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            [B]return[/B] [B]this[/B].feedbackId;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      }[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]      …[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]}[/FONT][/COLOR]
    Meine Klassen sind wie folgt gemappt:

    1.Klasse Patient

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    
     [COLOR=black][FONT=&quot]<?xml version="1.0"?>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<!-- Generated 20.12.2006 [/FONT][/COLOR][COLOR=black][FONT=&quot]20:30:41[/FONT][/COLOR][COLOR=black][FONT=&quot] by Hibernate Tools 3.1.0.beta5 -->[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<hibernate-mapping>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]    <class name="ipis.domain.Patient" table="patient" catalog="ipis">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<comment></comment>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        <id name="patientId" type="int">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <column name="patient_id" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <generator class="assigned" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]</id>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]        <set name="feedbacks" [/FONT][/COLOR][COLOR=black][FONT=&quot]inverse="true"[/FONT][/COLOR][COLOR=black][FONT=&quot]>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <key>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                <column name="patient_id" not-null="true">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                    <comment></comment>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                </column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            </key>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <one-to-many class="ipis.domain.Feedback" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        </set>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        <set name="chemotests" inverse="true">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <key>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                <column name="patient_id" not-null="true">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                    <comment></comment>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                </column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            </key>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <one-to-many class="ipis.domain.Chemotest" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        </set>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]    </class>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]</hibernate-mapping>[/FONT][/COLOR]



    2.Klasse Feedback

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
     
      [COLOR=black][FONT=&quot]<?xml version="1.0"?>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<!-- Generated 20.12.2006 [/FONT][/COLOR][COLOR=black][FONT=&quot]20:30:41[/FONT][/COLOR][COLOR=black][FONT=&quot] by Hibernate Tools 3.1.0.beta5 -->[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<hibernate-mapping>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]    <class name="ipis.domain.Feedback" table="feedback" catalog="ipis">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        <comment></comment>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        <id name="feedbackId" type="int">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <column name="feedback_id" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <generator class="increment" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        </id>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        <many-to-one name="patient" class="ipis.domain.Patient" fetch="select">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <column name="patient_id" not-null="true">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                <comment></comment>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            </column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        </many-to-one>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        <property name="feedbackText" type="string">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            <column name="feedback_text" length="65535" not-null="true">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                <comment></comment>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]            </column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        </property>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]    </class>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]</hibernate-mapping>[/FONT][/COLOR]


    In der Frontend-Schicht möchte ich die Daten über den Patienten und seine Feedbacks anzeigen, meine JSF-Seite sieht so aus:



    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    
     
     
    [COLOR=black][FONT=&quot]<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]<html>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<%@ include file="../base/includeHeader.jsp" %>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<body>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]<f:view>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<%@ include file="top.jsp"%>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot] <h2>My data</h2>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]  <h:form id="form">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]   <table>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      <h:dataTable value="#{patientAction.currentPatient}" var="patient"[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      border="1" >[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]     <h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]       <h:outputText value="Identifier" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]     </h:column>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]     <h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]       <h:outputText value="#{patient.patientId}" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]     </h:column>[/FONT][/COLOR]
      
      
      [COLOR=black][FONT=&quot]    <h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      <h:dataTable value="#{patient.feedbacks}" var="feedbacks"[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      border="1">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]    <h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      [B][COLOR=Red]<h:outputText value="#{feedbacks.type}" />[/COLOR][/B][/FONT][/COLOR]
      [COLOR=black][FONT=&quot]    </h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      </h:dataTable>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]    </h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]   </h:dataTable>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]</table>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]</h:form>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]</f:view>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]</body>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]</html>[/FONT][/COLOR]


    Schön wäre es wenn es so funktionieren würde, leider wird folgendes Exception geworfen:


    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    
     [COLOR=black]
    [/COLOR]
      
      [COLOR=black][FONT=&quot]2007-01-22 15:26:02,317 ERROR [org.apache.myfaces.shared_impl.renderkit.RendererUtils] - Property not found - called by component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /ipis-jsp/mydata.jsp][Class: javax.faces.component.html.HtmlForm,Id: form][Class: javax.faces.component.html.HtmlDataTable,Id: _idJsp5][Class: javax.faces.component.UIColumn,Id: _idJsp10][Class: javax.faces.component.html.HtmlDataTable,Id: _idJsp11][Class: javax.faces.component.UIColumn,Id: _idJsp12][Class: javax.faces.component.html.HtmlOutputText,Id: _idJsp13]}[/FONT][/COLOR]
      [B][U][COLOR=black][FONT=&quot]javax.faces.el.PropertyNotFoundException[/FONT][/COLOR][/U][COLOR=black][FONT=&quot]: Bean: org.hibernate.collection.PersistentSet, property: type[/FONT][/COLOR]
      [/B][COLOR=black][FONT=&quot][B]      at[/B] org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor([U]PropertyResolverImpl.java:483[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor([U]PropertyResolverImpl.java:454[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.el.PropertyResolverImpl.getProperty([U]PropertyResolverImpl.java:417[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.el.PropertyResolverImpl.getValue([U]PropertyResolverImpl.java:82[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate([U]ELParserHelper.java:532[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.commons.el.ComplexValue.evaluate([U]ComplexValue.java:145[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.el.ValueBindingImpl.getValue([U]ValueBindingImpl.java:383[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at javax.faces.component.UIOutput.getValue([U]UIOutput.java:77[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue([U]RendererUtils.java:217[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderOutput([U]HtmlTextRendererBase.java:69[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd([U]HtmlTextRendererBase.java:57[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at javax.faces.component.UIComponentBase.encodeEnd([U]UIComponentBase.java:536[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild([U]RendererUtils.java:442[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChildren([U]RendererUtils.java:419[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild([U]RendererUtils.java:440[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.html.HtmlTableRendererBase.renderColumnBody([U]HtmlTableRendererBase.java:212[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.html.HtmlTableRendererBase.encodeColumnChild([U]HtmlTableRendererBase.java:181[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.html.HtmlTableRendererBase.encodeInnerHtml([U]HtmlTableRendererBase.java:167[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.html.HtmlTableRendererBase.encodeChildren([U]HtmlTableRendererBase.java:100[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at javax.faces.component.UIComponentBase.encodeChildren([U]UIComponentBase.java:524[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild([U]RendererUtils.java:436[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChildren([U]RendererUtils.java:419[/U])[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild([U]RendererUtils.java:440[/U])[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]…[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]…[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]…[/FONT][/COLOR]
        [COLOR=black] 
    [/COLOR]


    Ich bin Absolut neu in JSF und JSP, ich weiss nicht wie ich dieses Problem überwende.
    Vielleicht muss ich hier List statt Set benutzen, stimmt mir jemand zu? Wenn ja wie geht's das?

    Ich würde mich sehr freune über eine Antwort.
    Danke im Voraus.
     

  2. #2
    Registriert seit
    Jun 2002
    Ort
    Saarbrücken (Saarland)
    Beiträge
    9.886
    Blog-Einträge
    29
    Hallo!

    Im Hibernate Mapping für Feedback fehelen die Properties für:
    Code :
    1
    2
    3
    
       private byte type;
      
            private Date date;

    Weiterhin brauchst du dafür auch entsprechende (public) getter / setter Methoden in der Klasse Feedback, dann sollte es klappen.

    Gruß Tom
     
    Java rocks!
    How to become a good Java Programmer?
    Does IT in Java and .Net
    The only valid measurement of code quality: WTFs / minute
    Blog
    Xing
    Twitter

  3. #3
    mahosand mahosand ist offline Mitglied
    Registriert seit
    Oct 2004
    Beiträge
    15
    Hallo Tom,
    vielen dank für deine Antwort!
    Es tut mir Leid ich wollte ein bißschen kürzen und habe ein paar Zeilen gelöscht
    Hier ist der vollständige Code
    Das hibernate mapping:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    
     
    <hibernate-mapping>
        <class name="ipis.domain.Feedback" table="feedback" catalog="ipis">
            <comment></comment>
            <id name="feedbackId" type="int">
                <column name="feedback_id" />
                <generator class="increment" />
            </id>
            <many-to-one name="patient" class="ipis.domain.Patient" fetch="select">
                <column name="patient_id" not-null="true">
                    <comment></comment>
                </column>
            </many-to-one>
            <property name="feedbackText" type="string">
                <column name="feedback_text" length="65535" not-null="true">
                    <comment></comment>
                </column>
            </property>
            <property name="type" type="byte">
                <column name="type" not-null="true">
                    <comment></comment>
                </column>
            </property>
            <property name="date" type="timestamp">
                <column name="date" length="19" not-null="true">
                    <comment></comment>
                </column>
            </property>
        </class>
    </hibernate-mapping>
    und die Feedback-Klasse

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    
    package ipis.domain;
     
    // Generated 20.12.2006 20:30:40 by Hibernate Tools 3.1.0.beta5
     
    import java.util.Date;
     
    /**
     * Feedback generated by hbm2java
     */
    public class Feedback implements java.io.Serializable {
     
        // Fields    
     
        private int feedbackId;
     
        private Patient patient;
     
        private String feedbackText;
     
        private byte type;
     
        private Date date;
     
        // Constructors
     
        /** default constructor */
        public Feedback() {
        }
     
        /** full constructor */
        public Feedback(int feedbackId, Patient patient, String feedbackText,
                byte type, Date date) {
            this.feedbackId = feedbackId;
            this.patient = patient;
            this.feedbackText = feedbackText;
            this.type = type;
            this.date = date;
        }
     
        // Property accessors
        public int getFeedbackId() {
            return this.feedbackId;
        }
     
        public void setFeedbackId(int feedbackId) {
            this.feedbackId = feedbackId;
        }
     
        public Patient getPatient() {
            return this.patient;
        }
     
        public void setPatient(Patient patient) {
            this.patient = patient;
        }
     
        public String getFeedbackText() {
            return this.feedbackText;
        }
     
        public void setFeedbackText(String feedbackText) {
            this.feedbackText = feedbackText;
        }
     
        public byte getType() {
            return this.type;
        }
     
        public void setType(byte type) {
            this.type = type;
        }
     
        public Date getDate() {
            return this.date;
        }
     
        public void setDate(Date date) {
            this.date = date;
        }
     
    }
    Muss ich irgendwo irgenwelche Konifurationen machen?
    Ich habe eine Datei : ApplictionContextJSF.xml die spring-Bean.Definitionen enthält, und wird in Faces-config.xml geladen:

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    
     
    <?xml version="1.0" encoding="UTF-8"?>
     
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
        default-autowire="byType">
     
        
        <!-- Für die Fehlermeldungen und Meldungen -->
        <bean id="messageSource"
            class="org.springframework.context.support.ResourceBundleMessageSource">
            <property name="basenames">
                <list>
                    <value>errors</value>
                    <value>ipis.auth.messages</value>
                </list>
            </property>
        </bean>
        
        
        <bean id="feedbackAction" class="ipis.web.jsf.FeedbackAction">
            <property name="feedbackServiceI" ref="feedbackServiceI" />
            <property name="feedbackDaoI" ref="feedbackDaoI" />
            <property name="patientAuthService" ref="patientAuthService" />
        </bean>
        
        
        <bean name="patientAuthService" class="ipis.auth.PatientAuthServiceImpl">
            <property name="authenticationManager"
                ref="authenticationManager" />
            <property name="patientDaoI" ref="patientDaoI" />
        </bean>
        
        <bean id="patientAction"
            class="ipis.web.jsf.PatientAction">
            <property name="patientServiceI" ref="patientServiceI" />
            <property name="patientAuthService" ref="patientAuthService" />
            <property name="patientDaoI" ref="patientDaoI" />
            <property name="messageSource" ref="messageSource" />
        </bean>
        
         <!-- session scope -->
         <bean name="feedback"
            class="ipis.domain.Feedback"
            scope="session">
        </bean>
        
       
        <!-- request scope -->
        <bean name="patient"
            class="ipis.domain.Patient"
            scope="request">
        </bean>
      
    </beans>
    Ich weiss nicht warum die Properties von Feedback nicht erkannt werden, HILFE

    Brauche ich irgenwie ein converter?

    Gruß Hind
     

  4. #4
    mahosand mahosand ist offline Mitglied
    Registriert seit
    Oct 2004
    Beiträge
    15
    Noch eine Frage :
    Ich habe in der Datenbank für das Attribut "gender" , eine 0 oder 1 gespeichert, wenn es eine 1 ist, dann heißt es, dass gender Männlich ist , und wenn 0 dann heißt es, dass gender Weiblich ist.
    Ich möchte in der Ausgabe , statt 0 oder 1 , Männlich oder Weiblich ausgeben.
    Mein Code sieht so aus:

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    
     
    [COLOR=black][FONT=&quot]<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]<html>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<%@ include file="../base/includeHeader.jsp" %>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<body>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]<f:view>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]<%@ include file="top.jsp"%>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot] <h2>My data</h2>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]  <h:form id="form">[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]   <table>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      <h:dataTable value="#{patientAction.currentPatient}" var="patient"[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      border="1" >[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]     <h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]       <h:outputText value="Identifier" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]     </h:column>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]     <h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]       <h:outputText value="#{patient.patientId}" />[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]     </h:column>
     
    [/FONT][/COLOR]     [COLOR=Blue]<h:column>
     
        <% if(%>${patient.gender}<%==1) %>
                          
            <h:outputText value="Weiblich" />
                          
          </h:column>
         [/COLOR]
     
      
      [COLOR=black][FONT=&quot]    <h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      <h:dataTable value="#{patient.feedbacks}" var="feedbacks"[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      border="1">
     
    [/FONT][/COLOR]  [COLOR=black][FONT=&quot]    <h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      [COLOR=Black]<h:outputText value="#{feedbacks.type}" />[/COLOR][/FONT]
      [/COLOR][COLOR=black][FONT=&quot]    </h:column>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]      </h:dataTable>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]    </h:column>
     
    [/FONT][/COLOR]  [COLOR=black][FONT=&quot]   </h:dataTable>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]</table>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]</h:form>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]</f:view>[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]</body>[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]</html>[/FONT][/COLOR]
    Das in Blau markierte code war einer der Versuche. Bitte wenn jemand weiss wie es geht, bitte meldet euch.
     

Ähnliche Themen

  1. Hibernate Collection mergen
    Von sebastianb im Forum Java
    Antworten: 0
    Letzter Beitrag: 27.09.10, 12:59
  2. Hibernate/JPA Collection
    Von Peregrin im Forum Java
    Antworten: 0
    Letzter Beitrag: 26.01.10, 10:41
  3. Hibernate: illegal access to loading collection
    Von Kryptaesthesie im Forum Java
    Antworten: 4
    Letzter Beitrag: 29.12.09, 13:18
  4. Antworten: 2
    Letzter Beitrag: 13.06.07, 09:24
  5. Hibernate List Problem
    Von e.motion im Forum Java
    Antworten: 9
    Letzter Beitrag: 18.02.05, 15:40