-->
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.  [ 3 posts ] 
Author Message
 Post subject: Using a UserType to compare Dates with Restrictions
PostPosted: Thu Apr 10, 2008 12:01 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 11:53 am
Posts: 23
This is my UserType code:
Code:
public class DateUserType implements UserType
{
   private static final int[] SQL_TYPES = new int[] { Types.TIMESTAMP };
   
   public DateUserType(){
       super();
   }
 
   public int[] sqlTypes() {
      return SQL_TYPES;
   }

 
   public Class returnedClass() {
      return java.util.Date.class;
   }
   
   
   public boolean equals(Object x, Object y) throws HibernateException {
      if( x==y ) return true;
      if( (x==null) || (y==null) ) return false;
   
      return x.equals(y);
   }

   
   public Object nullSafeGet(ResultSet rs, String[] names, Object owner)throws HibernateException, SQLException
   {

      Timestamp timestamp = (Timestamp) Hibernate.TIMESTAMP.nullSafeGet(rs, names[0]);//I think so :(     

      // return Date (cut out the precision)
      if( timestamp==null )
      {
         return null;
      }
      else
      {   
         return new Date(timestamp.getTime());
      }
   }


 
   public void nullSafeSet(PreparedStatement st, Object value, int index)throws HibernateException, SQLException
   {
      // handle the NULL
      if( value==null )
      {
         st.setTimestamp(index, null);
         return;
      }
     
     
      if( ! Date.class.isAssignableFrom(value.getClass()) ) {
         throw new IllegalArgumentException("Required a (java.util.Date) but received a [" + value.getClass() + "]");
      }

     
      Timestamp tstamp = null;
      if( (value instanceof Timestamp) )
      {
         tstamp = (Timestamp) value;
      }
      else
      {
         tstamp = new Timestamp( ((Date) value).getTime() );
      }
     
      st.setTimestamp(index, tstamp);
   }



   public Object deepCopy(Object value) throws HibernateException {
      if( value==null )
      {
         return null;
      }
      else
      {   
         return ((Date) value).clone();
      }
   }

 
   public boolean isMutable() {
      return true;
   }
   
   //optional
   public Serializable disassemble(Object value) throws HibernateException {
        return (Serializable) value;
    }

    public Object assemble(Serializable cached, Object owner) throws HibernateException {
        return cached;
    }

    public Object replace(Object original, Object target, Object owner) throws HibernateException {
        return original;
    }
   
    public int hashCode(Object x){
        return x.hashCode();
    }

}



This is a partial of my object that uses DateUserType:

Code:
public class HibernateRequestObject implements HibernateObject{
    private Long requestId;
    private Date dateCreated;
   

    public Long getRequestId() {
        return requestId;
    }

    public void setRequestId(Long requestId) {
        this.requestId = requestId;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }



This is a partial of my xml mapping:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="net.taxstream.transferpricing.domain">
    <class name="HibernateRequestObject" table="HIBERNATEREQUESTOBJECT2">
        <id name="requestId" column="request_id" type="long">
            <generator class="sequence"/>
        </id>
        <property name="dateCreated" column="date_created" type="net.tp.util.DateUserType"/>
        <property name="division"/>


This is the Oracle 10g sql code for the table I am retrieving the date from:
Code:
create table requests (
    id integer,
    date_created date default sysdate constraint nn_requests_date_created not null,
    constraint pk_requests primary key (id)
);


That's it, but it still doesn't work when I use the Criterion in the following code snippet:
Code:
public class CriterionFactoryForFilterTypes {
    private final static ArrayList<Criterion> criterion;
    private final static SimpleDateFormat format;
    private final static Logger log;
   
    static{
        criterion = new ArrayList<Criterion>();
        format = new SimpleDateFormat("dd-MMM-yy");
        log = Logger.getLogger(CriterionFactoryForFilterTypes.class);
    }
...
if(type.equals("date"))
            {
                try
                {
                    date = format.parse(filter.getValue().trim());
                }
                catch(ParseException pe)
                {
                    throw new RuntimeException("The date was not formatted correctly [ " + filter.getValue().trim() + "]");
                }               
                switch(filter.getComparison())
                {
                    case eq:criterion.add(Restrictions.eq(filter.getField(), date));break;
                    case lt:criterion.add(Restrictions.lt(filter.getField(), date));break;
                    case gt:criterion.add(Restrictions.gt(filter.getField(), date));break;
                }               
            }
           


Does anyone have any suggestions on what I am doing wrong, thanks.


Top
 Profile  
 
 Post subject: Any responses!!!!
PostPosted: Thu Apr 10, 2008 2:56 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 11:53 am
Posts: 23
I know someone must have encountered this issue on Oracle 10g using Hibernate 3.2 or some other combination -- I just don't know why this doesn't work :( And also is TestNG the best framework to test Hibernate with. What about ORMUnit, thanks.


Top
 Profile  
 
 Post subject: Must be a BUG in Hibernate
PostPosted: Thu Apr 10, 2008 7:58 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 11:53 am
Posts: 23
Hibernate version: 3.2.4.sp1
Mapping documents: Using XML
Name and version of the database you are using: Oracle XE/10G

Stemming from my earlier post, I did some further testing and found some interesting quirks
http://forum.hibernate.org/viewtopic.php?t=985706

Code:
cing.util.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:30,901 INFO [net.tp.FilterToHibernateMapper] - <Criteria info CriteriaImpl(net.tp.HibernateRequestObject:this[][])>
Hibernate: select * from ( select this_.request_id as request1_0_0_, this_.date_created as date2_0_0_, this_.division as division0_0_, this_.product_group as product4_0_0_, this_.sale_reporting_code as sale5_0_0_, this_.product_type as product6_0_0_, this_.territory as territory0_0_, this_.presentation as presenta8_0_0_, this_.unitId as unitId0_0_, this_.code as code0_0_, this_.name as name0_0_, this_.unit_typeid as unit12_0_0_, this_.countryTypeId as country13_0_0_, this_.country as country0_0_, this_.collectionId as collect15_0_0_, this_.col_code as col16_0_0_, this_.col_name as col17_0_0_, this_.col_componenttypeid as col18_0_0_, this_.cstateId as cstateId0_0_, this_.cs_code as cs20_0_0_, this_.cs_name as cs21_0_0_, this_.cs_shortcode as cs22_0_0_ from HIBERNATEREQUESTOBJECT2 this_ order by this_.request_id asc ) where rownum <= ?
2008-04-10 19:10:30,947 INFO [net.taxstream.transferpricing.util.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:30,947 INFO [net.tp.util.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:30,947 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:30,947 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:30,947 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,026 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,026 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,026 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,026 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,026 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,135 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,135 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,135 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,166 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,166 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,229 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,229 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,229 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,229 INFO [net.tp.DateUserType] - < The date coming back 1196658000000>
2008-04-10 19:10:31,229 INFO [net.tp.DateUserType] - < [u]The date coming back 1196658000000[/u]>
2008-04-10 19:11:20,369 INFO [net.tp.CriterionFactoryForFilterTypes] - <[u]From the criterion factory 1196658000000 and pattern yyyy-MM-dd[/u]>
Hibernate: select this_.request_id as request1_0_0_, this_.date_created as date2_0_0_, this_.division as division0_0_, this_.product_group as product4_0_0_, this_.sale_reporting_code as sale5_0_0_, this_.product_type as product6_0_0_, this_.territory as territory0_0_, this_.presentation as presenta8_0_0_, this_.unitId as unitId0_0_, this_.code as code0_0_, this_.name as name0_0_, this_.unit_typeid as unit12_0_0_, this_.countryTypeId as country13_0_0_, this_.country as country0_0_, this_.collectionId as collect15_0_0_, this_.col_code as col16_0_0_, this_.col_name as col17_0_0_, this_.col_componenttypeid as col18_0_0_, this_.cstateId as cstateId0_0_, this_.cs_code as cs20_0_0_, this_.cs_name as cs21_0_0_, this_.cs_shortcode as cs22_0_0_ from HIBERNATEREQUESTOBJECT2 this_ where this_.date_created=? and 1=1 order by this_.request_id asc
2008-04-10 19:11:20,447 INFO [net.tp.FilterToHibernateMapper] - <Criteria info CriteriaImpl(net.tp.HibernateRequestObject:this[][dateCreated=Mon Dec 03 00:00:00 EST 2007, ()])>
Hibernate: select * from ( select this_.request_id as request1_0_0_, this_.date_created as date2_0_0_, this_.division as division0_0_, this_.product_group as product4_0_0_, this_.sale_reporting_code as sale5_0_0_, this_.product_type as product6_0_0_, this_.territory as territory0_0_, this_.presentation as presenta8_0_0_, this_.unitId as unitId0_0_, this_.code as code0_0_, this_.name as name0_0_, this_.unit_typeid as unit12_0_0_, this_.countryTypeId as country13_0_0_, this_.country as country0_0_, this_.collectionId as collect15_0_0_, this_.col_code as col16_0_0_, this_.col_name as col17_0_0_, this_.col_componenttypeid as col18_0_0_, this_.cstateId as cstateId0_0_, this_.cs_code as cs20_0_0_, this_.cs_name as cs21_0_0_, this_.cs_shortcode as cs22_0_0_ from HIBERNATEREQUESTOBJECT2 this_ where this_.date_created=? and 1=1 order by this_.request_id asc ) where rownum <= ?



The number 1196658000000 is the date.getTime() for the data instances that I am trying to evaluate whether they are equal using Criterion. <The date coming back 1196658000000>, is what is being pulled from the db when the resultset is returned.<From the criterion factory 1196658000000 and pattern yyyy-MM-dd> this is what I am sending through via the creation of criterion; as you can see the getTime() of both objects are the same yet still it returns a zero resultset when I run this from the web app. In the bottom I show the same thing with actual dates
Code:
Hibernate: select this_.request_id as request1_0_0_, this_.date_created as date2_0_0_, this_.division as division0_0_, this_.product_group as product4_0_0_, this_.sale_reporting_code as sale5_0_0_, this_.product_type as product6_0_0_, this_.territory as territory0_0_, this_.presentation as presenta8_0_0_, this_.unitId as unitId0_0_, this_.code as code0_0_, this_.name as name0_0_, this_.unit_typeid as unit12_0_0_, this_.countryTypeId as country13_0_0_, this_.country as country0_0_, this_.collectionId as collect15_0_0_, this_.col_code as col16_0_0_, this_.col_name as col17_0_0_, this_.col_componenttypeid as col18_0_0_, this_.cstateId as cstateId0_0_, this_.cs_code as cs20_0_0_, this_.cs_name as cs21_0_0_, this_.cs_shortcode as cs22_0_0_ from HIBERNATEREQUESTOBJECT2 this_ where this_.date_created=? and 1=1 order by this_.request_id asc
2008-04-10 19:17:06,635 INFO [net.tp.FilterToHibernateMapper] - <Criteria info CriteriaImpl(net.tp.HibernateRequestObject:this[][dateCreated=Mon Dec 03 00:00:00 EST 2007, ()])>
Hibernate: select * from ( select this_.request_id as request1_0_0_, this_.date_created as date2_0_0_, this_.division as division0_0_, this_.product_group as product4_0_0_, this_.sale_reporting_code as sale5_0_0_, this_.product_type as product6_0_0_, this_.territory as territory0_0_, this_.presentation as presenta8_0_0_, this_.unitId as unitId0_0_, this_.code as code0_0_, this_.name as name0_0_, this_.unit_typeid as unit12_0_0_, this_.countryTypeId as country13_0_0_, this_.country as country0_0_, this_.collectionId as collect15_0_0_, this_.col_code as col16_0_0_, this_.col_name as col17_0_0_, this_.col_componenttypeid as col18_0_0_, this_.cstateId as cstateId0_0_, this_.cs_code as cs20_0_0_, this_.cs_name as cs21_0_0_, this_.cs_shortcode as cs22_0_0_ from HIBERNATEREQUESTOBJECT2 this_ where this_.date_created=? and 1=1 order by this_.request_id asc ) where rownum <= ?
Hibernate: select this_.request_id as request1_0_0_, this_.date_created as date2_0_0_, this_.division as division0_0_, this_.product_group as product4_0_0_, this_.sale_reporting_code as sale5_0_0_, this_.product_type as product6_0_0_, this_.territory as territory0_0_, this_.presentation as presenta8_0_0_, this_.unitId as unitId0_0_, this_.code as code0_0_, this_.name as name0_0_, this_.unit_typeid as unit12_0_0_, this_.countryTypeId as country13_0_0_, this_.country as country0_0_, this_.collectionId as collect15_0_0_, this_.col_code as col16_0_0_, this_.col_name as col17_0_0_, this_.col_componenttypeid as col18_0_0_, this_.cstateId as cstateId0_0_, this_.cs_code as cs20_0_0_, this_.cs_name as cs21_0_0_, this_.cs_shortcode as cs22_0_0_ from HIBERNATEREQUESTOBJECT2 this_ order by this_.request_id asc
2008-04-10 19:17:34,822 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:34,838 INFO [net.tp.FilterToHibernateMapper] - <Criteria info CriteriaImpl(net.tp.HibernateRequestObject:this[][])>
Hibernate: select * from ( select this_.request_id as request1_0_0_, this_.date_created as date2_0_0_, this_.division as division0_0_, this_.product_group as product4_0_0_, this_.sale_reporting_code as sale5_0_0_, this_.product_type as product6_0_0_, this_.territory as territory0_0_, this_.presentation as presenta8_0_0_, this_.unitId as unitId0_0_, this_.code as code0_0_, this_.name as name0_0_, this_.unit_typeid as unit12_0_0_, this_.countryTypeId as country13_0_0_, this_.country as country0_0_, this_.collectionId as collect15_0_0_, this_.col_code as col16_0_0_, this_.col_name as col17_0_0_, this_.col_componenttypeid as col18_0_0_, this_.cstateId as cstateId0_0_, this_.cs_code as cs20_0_0_, this_.cs_name as cs21_0_0_, this_.cs_shortcode as cs22_0_0_ from HIBERNATEREQUESTOBJECT2 this_ order by this_.request_id asc ) where rownum <= ?
2008-04-10 19:17:34,901 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:34,901 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:34,901 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:34,916 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:34,994 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:34,994 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:34,994 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:34,994 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,104 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,104 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,104 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,104 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,197 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,229 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,229 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,229 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,322 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,322 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>
2008-04-10 19:17:35,322 INFO [net.tp.DateUserType] - < The date coming back Mon Dec 03 00:00:00 EST 2007>



So you can see<Criteria info CriteriaImpl(net.tp.HibernateRequestObject:this[][dateCreated=Mon Dec 03 00:00:00 EST 2007, ()])>, this is from the actual Criteria.toString() showing the date passed in the query and of course < The date coming back Mon Dec 03 00:00:00 EST 2007> this is from the UserType implementation which shows the exact same thing, the dates are identical yet it does not match and I receive no results.

Below is my implementation of UserType, modified from my earlier post
Code:

import java.io.Serializable;
import org.hibernate.usertype.UserType;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;

import java.util.Date;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.apache.log4j.Logger;



/**
* @author kshabazz
*
*This is necessary cause the precision of the returned Timestamp type causes it
*to fail when compared to a Date
*/
public class DateUserType implements UserType
{
   private static final int[] SQL_TYPES = new int[] { Types.TIMESTAMP };
   private static final Logger log = Logger.getLogger(DateUserType.class);
   private static final DateFormat shortDate=new SimpleDateFormat("yyyy-MM-dd");
   
   public DateUserType(){
       super();
   }
 
   public int[] sqlTypes() {
      return SQL_TYPES;
   }

 
   public Class returnedClass() {
      return java.util.Date.class;
   }
   
   
   public boolean equals(Object x, Object y) throws HibernateException {
        if (x instanceof Date) {
                Date date1 = (Date) x;
            if (y instanceof Date) {
                Date date2 = (Date) y;
            //if(shortDate.format(date1).equalsIgnoreCase(shortDate.format(date2))){
              if(date1.equals(date2)){
                return true;
                }
            }
        }
        return false;
   }

   
   public Object nullSafeGet(ResultSet rs, String[] names, Object owner)throws HibernateException, SQLException
   {
      Date date;
      long milliseconds;
      Timestamp timestamp = (Timestamp) Hibernate.TIMESTAMP.nullSafeGet(rs, names[0]);//I think so :(
             
      if( timestamp==null )
      {
         return null;
      }
      else
      {   
         milliseconds = timestamp.getTime() + (timestamp.getNanos() / 1000000);
         try {
            log.info(" The date coming back "+shortDate.parse(shortDate.format(milliseconds))); 
            return shortDate.parse(shortDate.format(milliseconds));
         }
         catch(ParseException pe){
             throw new RuntimeException(pe.getMessage());
         }
         
      }
   }


 
   public void nullSafeSet(PreparedStatement st, Object value, int index)throws HibernateException, SQLException
   {
      // handle the NULL
      if( value==null )
      {
         st.setTimestamp(index, null);
         return;
      }
     
     
      if( ! Date.class.isAssignableFrom(value.getClass()) ) {
         throw new IllegalArgumentException("Required a (java.util.Date) but received a [" + value.getClass() + "]");
      }

     
      Timestamp tstamp = null;
      if( (value instanceof Timestamp) )
      {
         tstamp = (Timestamp) value;
      }
      else
      {
         tstamp = new Timestamp( ((Date) value).getTime() );
      }
     
      st.setTimestamp(index, tstamp);
   }



   public Object deepCopy(Object value) throws HibernateException {
      if( value==null )
      {
         return null;
      }
      else
      {   
         return ((Date) value).clone();
      }
   }

 
   public boolean isMutable() {
      return true;
   }
   
   //optional
   public Serializable disassemble(Object value) throws HibernateException {
        return (Serializable) value;
    }

    public Object assemble(Serializable cached, Object owner) throws HibernateException {
        return cached;
    }

    public Object replace(Object original, Object target, Object owner) throws HibernateException {
        return deepCopy(original);
    }
   
    public int hashCode(Object x){
        return x.hashCode();
    }

}


my criteria factory
Code:
public class CriterionFactoryForFilterTypes {
    private final static ArrayList<Criterion> criterion;
    private final static SimpleDateFormat format;
    private final static Logger log;
   
    static{
        criterion = new ArrayList<Criterion>();
        format = new SimpleDateFormat("yyyy-MM-dd");
        log = Logger.getLogger(CriterionFactoryForFilterTypes.class);
    }
        public static List<Criterion> matchTypeToCriteria(final List<Filter> filters){
          if(!criterion.isEmpty())
              criterion.clear();
          for(Filter f:filters)
              getCriteria(f);
          return Collections.unmodifiableList(criterion); 
        }
       
        private static void getCriteria(final Filter filter){
            Date date;
            final String type = filter.getType();
           
            if(type.equals("string"))
                criterion.add(Restrictions.ilike(filter.getField(),filter.getValue(),MatchMode.ANYWHERE));
           
            if(type.equals("numeric"))
            {
                switch(filter.getComparison())
                {
                    case eq:criterion.add(Restrictions.eq(filter.getField(), new Long(filter.getValue())));break;
                    case lt:criterion.add(Restrictions.lt(filter.getField(), new Long(filter.getValue())));break;
                    case gt:criterion.add(Restrictions.gt(filter.getField(), new Long(filter.getValue())));break;
                }
            }
           
            if(type.equals("date"))
            {
                try
                {
                    date = format.parse(filter.getValue().trim());
                }
                catch(ParseException pe)
                {
                    throw new RuntimeException("The date was not formatted correctly [ format: " + format.toPattern()+" value = "+filter.getValue().trim() + "]");
                }               
                switch(filter.getComparison())
                {
                   
                    case eq:criterion.add(Restrictions.eq(filter.getField(), date));log.info("From the criterion factory "+ date.getTime()+ " and pattern "+format.toPattern());break;
                    case lt:criterion.add(Restrictions.lt(filter.getField(), date));break;
                    case gt:criterion.add(Restrictions.gt(filter.getField(), date));break;
                }               
            }
           
            if(type.equals("list"))
            {
                String[] inParameters = filter.getValue().split(",");
                criterion.add(Restrictions.in(filter.getField(),inParameters));
            }
        }
       
       
}



Any ideas anyone???!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.