hib query returns null when the record IS in db:
Mapping document:
<hibernate-mapping>
<class name="fuckthegest.model.Magazzino" table="LOY_MAGAZZINO">
<composite-id>
<key-property name="cmp" type="string" column="C_CMP" />
<key-property name="codArt" type="string" column="C_COD_ART" />
<key-property name="pntVen" type="string" column="C_PNT_VEN" />
</composite-id>
<property name="qtaLim" type="int" column="N_QTA_LIM" />
<property name="qtaRif" type="int" column="N_QTA_RIF" />
</class>
<query name="fuckthegest.model.findMagazzino">
<![CDATA[
from fuckthegest.model.Magazzino as mag
where mag.cmp = :cmp
and mag.codArt = :codArt
and mag.pntVen = :pntVen
]]>
</query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Query query = session.getNamedQuery("fuckthegest.model.findMagazzino");
query.setString("cmp", cmp);
query.setString("codArt", art);
query.setString("pntVen", pntVen);
Magazzino magazzino = (Magazzino)query.uniqueResult();
at this poin magazzino is null, but if i execute the hib generated query i find the record
i mean the record is present in the db but query.uniqueResult() returns null !!
Name and version of the database you are using:
oracle
The generated SQL (show_sql=true):
select magazzino0_.C_CMP as C_CMP,
magazzino0_.C_COD_ART as C_COD_ART,
magazzino0_.C_PNT_VEN as C_PNT_VEN,
magazzino0_.N_QTA_LIM as N_QTA_LIM,
magazzino0_.N_QTA_RIF as N_QTA_RIF
from LOY_MAGAZZINO magazzino0_
where (magazzino0_.C_CMP=? )and(magazzino0_.C_COD_ART=? )and(magazzino0_.C_PNT_VEN=? )
i substitued ? with the actual values, executed the query and found the record .. now ... how is that possible
many thanx .. :D
|