1 Reply Latest reply on Feb 22, 2004 12:33 PM by Rafal Kedziorski

    MySQL: Compare dates

    Rudi Vankeirsbilck Newbie

       

      "Rudi Vankeirsbilck" wrote:
      "Rudi Vankeirsbilck" wrote:
      Hi all,

      platform information: Mac OS X, IntelliJ, JBoss 2.3.2, MySQL 4.0.16

      Currently, I am experiencing a problem with a query that is supposed to select entities who's date attribute is within a specified range.
      I have tried between first but that have me the following deployment error:
      10:14:53,443 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()'
      Cause: Incomplete Deployment listing:
      Packages waiting for a deployer:
      <none>
      Incompletely deployed packages:
      <none>
      MBeans waiting for classes:
      <none>
      MBeans waiting for other MBeans:
      [ObjectName: jboss.j2ee:jndiName=local/RecipientTimestamps,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'select object(o) from MailboxItem o, SmartMailbox smb where o.mailboxId = smb.id and smb.ownerId = ?1 and smb.organizationTypeString like 'D%' and smb.smartDate between ?2 and ?3'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "between" at line 1, column 162.
      Was expecting one of:
      ">" ...
      "<" ...
      "=" ...
      "<>" ...
      )]


      I then resorted to ordinary expressions (using <= and >=) but got a similar deployment errror:
      10:17:17,907 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()'
      Cause: Incomplete Deployment listing:
      Packages waiting for a deployer:
      <none>
      Incompletely deployed packages:
      <none>
      MBeans waiting for classes:
      <none>
      MBeans waiting for other MBeans:
      [ObjectName: jboss.j2ee:jndiName=local/RecipientTimestamps,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'select object(o) from MailboxItem o, SmartMailbox smb where o.mailboxId = smb.id and smb.ownerId = ?1 and smb.organizationTypeString like 'D%' and smb.smartDate >= ?2 and smb.smartDate <= ?3'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered ">=" at line 1, column 162.
      Was expecting one of:
      ">" ...
      "<" ...
      "=" ...
      "<>" ...
      )]


      Finally, I decided to change the date range before calling the finder method so that I could use < and >. The code deploys fine but does not give the expected results. The query returns no entities where it should return 9.

      Any help would be appreciated.

      Rudi.