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.  [ 9 posts ] 
Author Message
 Post subject: Why does Criteria return null component ?
PostPosted: Thu Mar 02, 2006 7:10 am 
Beginner
Beginner

Joined: Tue Jul 05, 2005 4:44 am
Posts: 40
Location: Paris, France
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

_________________
Fred


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 6:39 am 
Beginner
Beginner

Joined: Tue Jul 05, 2005 4:44 am
Posts: 40
Location: Paris, France
I try to used query and i have the same error

Code:
      String query =
      "from Gate as gate " +
      "where " +
      "and gate.beginApplication.hours = :beginHour " +
      "and gate.beginApplication.offSet = :beginOffSet " +
      "and gate.endApplication.hours = :endHour " +
      "and gate.endApplication.offSet = :endOffSet ";
      
      Query q = HibernateUtil.getSession().createQuery(SELECT_BY_PROCESS_AND_APPLICATION_DATE);
      q.setParameter("beginHour", beginHour);
      q.setParameter("endHour", endHour);
      q.setParameter("beginOffSet", beginOffSet);
      q.setParameter("endOffSet", endOffSet);
      List result = new ArrayList();


Any ideas ?
Thanks

_________________
Fred


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 6:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if your database contains null values for all columns of a component then we return null....that is just default behavior.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 9:01 am 
Beginner
Beginner

Joined: Tue Jul 05, 2005 4:44 am
Posts: 40
Location: Paris, France
max wrote:
if your database contains null values for all columns of a component then we return null....that is just default behavior.

Thx for your answer Max.
But for my case, all component properties have not-null="true".

_________________
Fred


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 12:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not-null="true" does not magically convert any existing null values to non-null...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 05, 2006 6:57 pm 
Beginner
Beginner

Joined: Tue Jul 05, 2005 4:44 am
Posts: 40
Location: Paris, France
max wrote:
not-null="true" does not magically convert any existing null values to non-null...
Hi Max;

First, I check database. The databases does not contain not value.

Second, To test, I have modified the hibernate configuration :
I haved replace the component by a many-to-one relation (with cascade="all") and I have mapped the class GateDate.

I test with the same case :
- add the same object ;
- do the same request.
and I have not this error.

I think this component error can come from the environment : I work in a Weblogic Cluster Environment.

_________________
Fred


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 7:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Quote:
First, I check database. The databases does not contain not value.


huh?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 4:47 am 
Beginner
Beginner

Joined: Tue Jul 05, 2005 4:44 am
Posts: 40
Location: Paris, France
sorry for my french-english :)

I wanted to say in the database, all columns used in my component contain not-null value.

_________________
Fred


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 2:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so something is wrong somewhere....if the data is returned correctly to hibernate it should already return components.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

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.