-->
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: newbie problem maybe about not null but empty varchar fields
PostPosted: Wed Mar 30, 2011 11:17 am 
Newbie

Joined: Wed Mar 30, 2011 10:52 am
Posts: 1
Hello, I'm a very newbie, so it could be a very stupid question.
I'm trying to select all from a table and I keep getting an error.

This is the mapping:


Code:
<hibernate-mapping>
    <class name="it.enpals.rodaocc.AliqContribE" table="ALIQ_CONTRIB_E" catalog="HOST">
        <composite-id name="id" class="it.enpals.rodaocc.AliqContribEId">
            <key-property name="codAliquota" type="string">
                <column name="COD_ALIQUOTA" length="2" />
            </key-property>
            <key-property name="dtIniVal" type="string">
                <column name="DT_INI_VAL" length="10" />
            </key-property>
        </composite-id>
        <property name="dtFinVal" type="string">
            <column name="DT_FIN_VAL" length="10" not-null="true" />
        </property>
        <property name="dscAliquota" type="string">
            <column name="DSC_ALIQUOTA" length="60" not-null="true" />
        </property>
        <property name="aliqCntBase" type="double">
            <column name="ALIQ_CNT_BASE" precision="22" scale="0" not-null="true" />
        </property>
        <property name="aliqCntBaseDat" type="double">
            <column name="ALIQ_CNT_BASE_DAT" precision="22" scale="0" not-null="true" />
        </property>
        <property name="aliqCntBaseLav" type="double">
            <column name="ALIQ_CNT_BASE_LAV" precision="22" scale="0" not-null="true" />
        </property>
        <property name="aliqCntSolid" type="double">
            <column name="ALIQ_CNT_SOLID" precision="22" scale="0" not-null="true" />
        </property>
        <property name="aliqCntSolidDat" type="double">
            <column name="ALIQ_CNT_SOLID_DAT" precision="22" scale="0" not-null="true" />
        </property>
        <property name="aliqCntSolidLav" type="double">
            <column name="ALIQ_CNT_SOLID_LAV" precision="22" scale="0" not-null="true" />
        </property>
        <property name="aliqCntAgg" type="double">
            <column name="ALIQ_CNT_AGG" precision="22" scale="0" not-null="true" />
        </property>
        <property name="minCntAgg" type="double">
            <column name="MIN_CNT_AGG" precision="22" scale="0" not-null="true" />
        </property>
        <property name="maxCntBase" type="double">
            <column name="MAX_CNT_BASE" precision="22" scale="0" not-null="true" />
        </property>
        <property name="maxCntSolid" type="double">
            <column name="MAX_CNT_SOLID" precision="22" scale="0" not-null="true" />
        </property>
        <property name="dtIns" type="string">
            <column name="DT_INS" length="10" not-null="true" />
        </property>
        <property name="trmIns" type="string">
            <column name="TRM_INS" length="6" not-null="true" />
        </property>
        <property name="uteIns" type="string">
            <column name="UTE_INS" length="8" not-null="true" />
        </property>
        <property name="dtAgg" type="string">
            <column name="DT_AGG" length="10" not-null="true" />
        </property>
        <property name="trmAgg" type="string">
            <column name="TRM_AGG" length="6" not-null="true" />
        </property>
        <property name="uteAgg" type="string">
            <column name="UTE_AGG" length="8" not-null="true" />
        </property>
        <property name="verCsl" type="string">
            <column name="VER_CSL" length="3" not-null="true" />
        </property>
        <property name="catGruppo" type="string">
            <column name="CAT_GRUPPO" length="3" not-null="true" />
        </property>
        <property name="tipoModello" type="string">
            <column name="TIPO_MODELLO" length="2" not-null="true" />
        </property>
        <property name="lavOldNew" type="char">
            <column name="LAV_OLD_NEW" length="1" not-null="true" />
        </property>
        <property name="verCslNeg" type="string">
            <column name="VER_CSL_NEG" length="3" not-null="true" />
        </property>
        <property name="tmsEstr" type="string">
            <column name="TMS_ESTR" length="26" />
        </property>
        <property name="idRiga" type="java.lang.Integer">
            <column name="ID_RIGA" />
        </property>
        <property name="tmsOper" type="string">
            <column name="TMS_OPER" length="26" />
        </property>
    </class>
</hibernate-mapping>


This is the code:


Code:
    public List<AliqContribE> getAliquote() {

        Session session = null;
        List<AliqContribE> retList = null;
        try {
            SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
            session = sessionFactory.openSession();


            //THIS WORKS -->retList = session.createCriteria(AliqContribE.class).add( Restrictions.like("dscAliquota", "LAV.SPORT")).list();
            retList = session.createCriteria(AliqContribE.class).list();

            for (AliqContribE a : retList){
                System.out.println(a.getDscAliquota());
                System.out.println(a.getId().getCodAliquota());
            }

        } catch (Exception e) {
           
            System.out.println(e.getMessage());

        } finally {
            session.flush();
            session.close();

        }
        return retList ;
    }



these are my logs:

30-mar-2011 17.03.44 org.hibernate.type.NullableType nullSafeGet
INFO: could not read column value from result set: LAV24_1_0_; String index out of range: 0
Exception in thread "main" java.lang.NullPointerException



I'm thinking that the problem rises because of my not-null but empty varchar/String fields, because the code retrieving a row that does have all field valued works well.

Am I right? And in this case, what's the solution?
I can't change my DB definition.

Thanx


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.