I am trying to limit a select from a logtable to the last so many days worth
of entries, but I get a class cast exception. Other criteria on same table
work OK, so I'm sure most of the setup is good. Am I missing something
really obvious? Is there an example available for querying by timestamp?

As a second question, the underlying database table has a compound primary
key across (log_time, ipm_session, command) .. how should that be mapped in
repository.xml? 

      Criteria criteria = new Criteria();
      java.sql.Timestamp t = new Timestamp(System.currentTimeMillis() -
(nDays * 24 * 60 * 60 * 1000));
      log.info("adding criteria greater than log_time " + t.toString());
      criteria.addGreaterThanField("log_time", t);
//      criteria.addEqualTo("remote_FQDN", "SU6878");
//      criteria.addOrderByDescending("log_time");
      Query query = QueryFactory.newQuery(IpmLogDTO.class, criteria);
      query.setStartAtIndex(1);
      broker = PersistenceBrokerFactory.defaultPersistenceBroker();
//ServiceLocator.getInstance().findBroker();
      log.info("calling getCollectionByQuery");
      results = (Collection) broker.getCollectionByQuery(query);


public class IpmLogDTO extends DataTransferObject
{
  /* ipm_log table is
   * Name                                      Null?    Type
----------------------------------------- --------
----------------------------
LOG_TIME                                  NOT NULL TIMESTAMP(3)
IPM_SESSION                               NOT NULL NUMBER(10)
LOCAL_HOST                                NOT NULL VARCHAR2(48)
REMOTE_HOST                               NOT NULL VARCHAR2(48)
REMOTE_FQDN                               NOT NULL VARCHAR2(48)
USER_NAME                                 NOT NULL VARCHAR2(48)
COMMAND                                   NOT NULL NUMBER(3)
PROCESSES                                 NOT NULL NUMBER(4)
SUBGROUP_ABREV                                     VARCHAR2(2)
SITEID                                             NUMBER(3)
RECTYPE                                            NUMBER(3)
MAXBACK                                            NUMBER(10)
LATEST                                             NUMBER(10)
SEARCH_TIME                                        DATE
RECORDS                                            NUMBER(7)
ELAPSED_SEC                                        NUMBER(7,3)
RECORDS_SEC                                        NUMBER(7,1)
KBYTES_SEC                                         NUMBER(7,1)

   */

  public Timestamp logTime;
  public int ipmSession;
  public String localHost;
  public String remoteHost;
  public String remoteFQDN;
...


  <class-descriptor class="com.vaisala.ice.vmdbReport.view.IpmLogDTO"
                    table="ipm_log">
    <!--n.b. primary key is actually (log_time, ipm_session, command), not
sure how to handle that in repository.xml -->
    <field-descriptor name="logTime" column="log_time" primarykey="true"
jdbc-type="TIMESTAMP"/>
    <field-descriptor name="ipmSession" column="ipm_session"
jdbc-type="INTEGER"/>
    <field-descriptor name="localHost" column="local_Host"
jdbc-type="VARCHAR"/>
    <field-descriptor name="remoteHost" column="remote_Host"
jdbc-type="VARCHAR"/>

Reply via email to