/ Forside / Teknologi / Udvikling / Java / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
Java
#NavnPoint
molokyle 3688
Klaudi 855
strarup 740
Forvirret 660
gøgeungen 500
Teil 373
Stouenberg 360
vnc 360
pmbruun 341
10  mccracken 320
Fejl ved hentning af data i Mysql via Hibe~
Fra : Brian Steensgaard


Dato : 21-02-06 18:38

Jeg har følgende Hibernate mapperfile:
<?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>
<class name="Person" table="PERSON">
<id name="id" type="long" column="PERSON_ID">
<generator class="native"/>
</id>
<property name="_FirstName" column="FirstName"/>
<property name="_LastName" column="LastName"/>
<property name="_MiddleName" column="MiddleName"/>
<property name="_SSN" column="SSN"/>
<component name="m_Address" class="Address">
<property name="_City" column="City"/>
<property name="_Country" column="Country"/>
<property name="_Street" column="Street"/>
</component>
<joined-subclass name="Doctor" table="DOCTOR">
<key column="PERSON_ID"/>
<property name="_OfficeNumber" column="OfficeNumber"/>
<property name="_PagerNumber" column="PagerNumber"/>
<set name="m_Patient" table="DOCTOR_PATIENT">
<key column="ref_DOCTOR_ID"/>
<many-to-many column="ref_PATIENT_ID" class="Patient"/>
</set>
</joined-subclass>
<joined-subclass name="Patient" table="PATIENT">
<key column="PERSON_ID" />
<property name="_MobilePhoneNumber" column="MobilePhoneNumber"/>
<property name="_PhoneNumber" column="PhoneNumber"/>
<set name="m_doctors" table="DOCTOR_PATIENT" inverse="true">
<key column="ref_PATIENT_ID"/>
<many-to-many column="ref_DOCTOR_ID" class="Doctor"/>
</set>
<set name="m_Record" table="PATIENT_RECORD">
<key column="ref_PATIENT_ID"/>
<many-to-many column="ref_JOURNAL_ID" class="Record"/>
</set>
</joined-subclass>
</class>

</hibernate-mapping>

Når jeg forsøger at hente en Patient med:
Patient aPatient = (Patient) session.load(Patient.class, patientId);

får jeg følgende fejl:
2006-02-21 18:29:52,343 ERROR JDBCExceptionReporter - Statement parameter 1
not set.
could not load an entity: [Patient#14]

Hvad kan det skyldes? Entryen findes i databasen, og Hibernate er sat
rigtigt op, så det er sandsynligvis en fejl i mapperfilen.



 
 
Brian Steensgaard (22-02-2006)
Kommentar
Fra : Brian Steensgaard


Dato : 22-02-06 03:15

Jeg har fundet ud af det.
"Brian Steensgaard" <theonlyone43221@hotmail.com> wrote in message
news:43fb4ff4$0$11674$ba624c82@nntp02.dk.telia.net...
> Jeg har følgende Hibernate mapperfile:
> <?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>
> <class name="Person" table="PERSON">
> <id name="id" type="long" column="PERSON_ID">
> <generator class="native"/>
> </id>
> <property name="_FirstName" column="FirstName"/>
> <property name="_LastName" column="LastName"/>
> <property name="_MiddleName" column="MiddleName"/>
> <property name="_SSN" column="SSN"/>
> <component name="m_Address" class="Address">
> <property name="_City" column="City"/>
> <property name="_Country" column="Country"/>
> <property name="_Street" column="Street"/>
> </component>
> <joined-subclass name="Doctor" table="DOCTOR">
> <key column="PERSON_ID"/>
> <property name="_OfficeNumber" column="OfficeNumber"/>
> <property name="_PagerNumber" column="PagerNumber"/>
> <set name="m_Patient" table="DOCTOR_PATIENT">
> <key column="ref_DOCTOR_ID"/>
> <many-to-many column="ref_PATIENT_ID" class="Patient"/>
> </set>
> </joined-subclass>
> <joined-subclass name="Patient" table="PATIENT">
> <key column="PERSON_ID" />
> <property name="_MobilePhoneNumber" column="MobilePhoneNumber"/>
> <property name="_PhoneNumber" column="PhoneNumber"/>
> <set name="m_doctors" table="DOCTOR_PATIENT" inverse="true">
> <key column="ref_PATIENT_ID"/>
> <many-to-many column="ref_DOCTOR_ID" class="Doctor"/>
> </set>
> <set name="m_Record" table="PATIENT_RECORD">
> <key column="ref_PATIENT_ID"/>
> <many-to-many column="ref_JOURNAL_ID" class="Record"/>
> </set>
> </joined-subclass>
> </class>
>
> </hibernate-mapping>
>
> Når jeg forsøger at hente en Patient med:
> Patient aPatient = (Patient) session.load(Patient.class, patientId);
>
> får jeg følgende fejl:
> 2006-02-21 18:29:52,343 ERROR JDBCExceptionReporter - Statement parameter
> 1 not set.
> could not load an entity: [Patient#14]
>
> Hvad kan det skyldes? Entryen findes i databasen, og Hibernate er sat
> rigtigt op, så det er sandsynligvis en fejl i mapperfilen.
>
>



Thorbjørn Ravn Ander~ (22-02-2006)
Kommentar
Fra : Thorbjørn Ravn Ander~


Dato : 22-02-06 09:57

"Brian Steensgaard" <theonlyone43221@hotmail.com> writes:

> Jeg har fundet ud af det.

Hvis nu du selv havde fundet overstående via en googlesøgning, ville
du så ikke have værdsat at få at vide hvad fejlen var?
--
Thorbjørn Ravn Andersen


Brian Steensgaard (22-02-2006)
Kommentar
Fra : Brian Steensgaard


Dato : 22-02-06 13:12

Jo - sorry.

Det var blandt andet fordi jeg brugt den forkerte dialect i opsætningsfilen.
Men jeg mener at denne specifikke fejl kom fordi jeg lavede gav funktion en
int med, hvor den forventede en long. Så følgende løste problemet:

Patient aPatient = (Patient) session.load(Patient.class, new
Long(patientId));

Brian Steensgaard

"Brian Steensgaard" <theonlyone43221@hotmail.com> wrote in message
news:43fbc925$0$11660$ba624c82@nntp02.dk.telia.net...
> Jeg har fundet ud af det.
> "Brian Steensgaard" <theonlyone43221@hotmail.com> wrote in message
> news:43fb4ff4$0$11674$ba624c82@nntp02.dk.telia.net...
>> Jeg har følgende Hibernate mapperfile:
>> <?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>
>> <class name="Person" table="PERSON">
>> <id name="id" type="long" column="PERSON_ID">
>> <generator class="native"/>
>> </id>
>> <property name="_FirstName" column="FirstName"/>
>> <property name="_LastName" column="LastName"/>
>> <property name="_MiddleName" column="MiddleName"/>
>> <property name="_SSN" column="SSN"/>
>> <component name="m_Address" class="Address">
>> <property name="_City" column="City"/>
>> <property name="_Country" column="Country"/>
>> <property name="_Street" column="Street"/>
>> </component>
>> <joined-subclass name="Doctor" table="DOCTOR">
>> <key column="PERSON_ID"/>
>> <property name="_OfficeNumber" column="OfficeNumber"/>
>> <property name="_PagerNumber" column="PagerNumber"/>
>> <set name="m_Patient" table="DOCTOR_PATIENT">
>> <key column="ref_DOCTOR_ID"/>
>> <many-to-many column="ref_PATIENT_ID" class="Patient"/>
>> </set>
>> </joined-subclass>
>> <joined-subclass name="Patient" table="PATIENT">
>> <key column="PERSON_ID" />
>> <property name="_MobilePhoneNumber" column="MobilePhoneNumber"/>
>> <property name="_PhoneNumber" column="PhoneNumber"/>
>> <set name="m_doctors" table="DOCTOR_PATIENT" inverse="true">
>> <key column="ref_PATIENT_ID"/>
>> <many-to-many column="ref_DOCTOR_ID" class="Doctor"/>
>> </set>
>> <set name="m_Record" table="PATIENT_RECORD">
>> <key column="ref_PATIENT_ID"/>
>> <many-to-many column="ref_JOURNAL_ID" class="Record"/>
>> </set>
>> </joined-subclass>
>> </class>
>>
>> </hibernate-mapping>
>>
>> Når jeg forsøger at hente en Patient med:
>> Patient aPatient = (Patient) session.load(Patient.class, patientId);
>>
>> får jeg følgende fejl:
>> 2006-02-21 18:29:52,343 ERROR JDBCExceptionReporter - Statement parameter
>> 1 not set.
>> could not load an entity: [Patient#14]
>>
>> Hvad kan det skyldes? Entryen findes i databasen, og Hibernate er sat
>> rigtigt op, så det er sandsynligvis en fejl i mapperfilen.
>>
>>
>
>



Søg
Reklame
Statistik
Spørgsmål : 177547
Tips : 31968
Nyheder : 719565
Indlæg : 6408797
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste