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