Hi,
In my mapping document, I use a component with
not-null properties.
To request my objet, I have used Criteria.
When I stress the application, the criteria returns sometimes a result with null component. And I don't understand why : First, with the same request, I can have a not null component or a null component.
Second, I have not null value in my database.
Is it a Criteria Bug or a bad component utilisation ?
Thank for your help.
Hibernate version: 3.2
Mapping documents:
Code:
<hibernate-mapping package="com.rte.etso.common.model.repository.etso">
<class name="Gate" table="GATE">
<id name="id" column="GATE_ID">
<generator class="sequence">
<param name="sequence">GATE_SEQ</param>
</generator>
</id>
<component name="beginApplication" class="GateDate">
<property name="hours"
column="GATE_BEGIN_APP_HOUR"
type="com.rte.etso.validation.persistence.hibernate.ApplicationHourType"
length="5"
not-null="true"/>
<property name="offSet"
column="GATE_BEGIN_APP_OFFSET"
type="com.rte.etso.validation.persistence.hibernate.OffSetDateType"
length="10"
not-null="true"/>
</component>
<component name="endApplication" class="GateDate" lazy="false">
<property name="hours"
column="GATE_END_APP_HOUR"
type="com.rte.etso.validation.persistence.hibernate.ApplicationHourType"
length="5"
not-null="true"/>
<property name="offSet"
column="GATE_END_APP_OFFSET"
type="com.rte.etso.validation.persistence.hibernate.OffSetDateType"
length="10"
not-null="true"/>
</component>
<component name="beginOpen" class="GateDate" lazy="false">
<property name="hours"
column="GATE_BEGIN_OPEN_HOUR"
type="com.rte.etso.validation.persistence.hibernate.ApplicationHourType"
length="5"
not-null="true"/>
<property name="offSet"
column="GATE_BEGIN_OPEN_OFFSET"
type="com.rte.etso.validation.persistence.hibernate.OffSetDateType"
length="10"
not-null="true"/>
</component>
<component name="endOpen" class="GateDate">
<property name="hours"
column="GATE_END_OPEN_HOUR"
type="com.rte.etso.validation.persistence.hibernate.ApplicationHourType"
length="5"
not-null="true"/>
<property name="offSet"
column="GATE_END_OPEN_OFFSET"
type="com.rte.etso.validation.persistence.hibernate.OffSetDateType"
length="10"
not-null="true"/>
</component>
<property name="name"
column="GATE_NAME"
length="64">
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): Criteria gateCriteria =
Code:
HibernateUtil.getSession().createCriteria(
Gate.class);
gateCriteria.add(Restrictions.eq(
"beginApplication.hours", beginHour));
gateCriteria.add(Restrictions.eq(
"beginApplication.offSet", beginOffSet));
gateCriteria.add(Restrictions.eq(
"endApplication.hours", endHour));
gateCriteria.add(Restrictions.eq(
"endApplication.offSet", endOffSet));
return gateCriteria.list();
Name and version of the database you are using: Oracle 9.2i
The generated SQL (show_sql=true):
Quote:
select
this_.GATE_ID as GATE1_15_1_,
this_.GATE_BEGIN_APP_HOUR as GATE2_15_1_,
this_.GATE_BEGIN_APP_OFFSET as GATE3_15_1_,
this_.GATE_END_APP_HOUR as GATE4_15_1_,
this_.GATE_END_APP_OFFSET as GATE5_15_1_,
this_.GATE_BEGIN_OPEN_HOUR as GATE6_15_1_,
this_.GATE_BEGIN_OPEN_OFFSET as GATE7_15_1_,
this_.GATE_END_OPEN_HOUR as GATE8_15_1_,
this_.GATE_END_OPEN_OFFSET as GATE9_15_1_,
this_.GATE_NAME as GATE10_15_1_,
from
GATE this_
where
this_.GATE_BEGIN_APP_HOUR=?
and this_.GATE_BEGIN_APP_OFFSET=?
and this_.GATE_END_APP_HOUR=?
and this_.GATE_END_APP_OFFSET=?
order by
this_.GATE_ORDER asc