-->
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: <many-to-one> not loading data from db
PostPosted: Tue Jul 05, 2011 5:59 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
Dear hibernate users, i have a method which returns a class of type PreventivoView.java defined as

Code:
public class PreventivoView {

    private String idPreventivo = null;
    private Richiedente richiedente = null;
    private StatoPreventivo statoPreventivo = null;
    private Struttura struttura = null;
    private TipoAttivita tipoAttivita = null;
    private SedeTecnica sedeTecnica = null;
    private String descrizione = "";

    PreventivoView() {}


with all his getters and setters defined, which I'll not write 'cause of TL;DR

then I have a method which should load one object of the above type, written as

Code:
    public PreventivoView getView() {
        String idPreventivo = getIdPreventivo();
        if (Value.isEmpty(view) &&
            Value.isNotEmpty(idPreventivo)) {
                view = (PreventivoView)
                    getSession().get(PreventivoView.class, idPreventivo);
        }
        return view;
    }


the object of type PreventivoView.java is not really a table, but a bunch of fields mapped as follows

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 package="previtc.model.preventivo">
    <class name="PreventivoView" table="P06_PREVENTIVI" mutable="false">
        <id name="idPreventivo" column="P06_ID_PREVENTIVO" type="string" />
        <!-- Relations -->
        <many-to-one name="richiedente"
                column="P06_ID_RICHIEDENTE"
                unique="true"
                update="false"
                insert="false"
                not-null="true" />
        <many-to-one name="esitoPreventivo"
                column="P06_TIPO_ESITO"
                unique="true"
                update="false"
                insert="false"
                not-null="true" />
        <many-to-one name="statoPreventivo"
                column="P06_TIPO_STATO"
                unique="true"
                update="false"
                insert="false"
                not-null="true" />
        <many-to-one name="struttura"
                column="P06_COD_STRUTTURA"
                unique="true"
                update="false"
                insert="false"
                not-null="true" />
        <many-to-one name="tipoAttivita"
                column="P06_TIPO_ATTIVITA"
                unique="true"
                update="false"
                insert="false"
                not-null="true" />
        <many-to-one name="sedeTecnica"
                column="P06_COD_SEDE_TECNICA"
                unique="true"
                update="false"
                insert="false"
                not-null="false" />
        <property name="descrizione"       
                column="P06_DESCRIZIONE"           
                type="string" />
    </class>
</hibernate-mapping>


I just want to understand why, at the moment of my query, my object is populated by the method which calls the query, without

any error, but the fields Richiedente , StatoPreventivo , TipoAttivita are not filled with datas! Constraints are correctly mapped in my

Oracle 10g database , as referential integrity . Could anyone explain me why the data are not loaded ? Thank you so much!


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.