3 Replies Latest reply on Feb 15, 2005 11:22 AM by Pat Osterday

    JBossQL, XDocletTags, and Date fields

    Hideki Mae Newbie

      To all:
      System: JBoss-3.2.4, Eclipse 2.1.3, Lomboz 2.1.3
      I was trying to create a finder method for a date field using JBoss-QL, since EJB-QL's support for date is restricted (problems with time information). I thought I could create the finder method using Xdoclet's @jboss.query tag but the compiler returned an error saying that the query method can not be found. I checked ejb-jar.xml and jbosscmp-jdbc.xml. It looks like the finder is put in jbosscmp-jdbc but ejb-jar.xml no longer has the finder method defined. Is there something I need to do?

      Thanks for all your help.

      Snippet of error message
      org.jboss.deployment.DeploymentException: Query method not found: findByDummyDate(java.sql.Date)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCQueryMetaDataFactory.getQueryMethods(JDBCQueryMetaDataFactory.java:322)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCQueryMetaDataFactory.getQueryMethods(JDBCQueryMetaDataFactory.java:243)

        • 1. Re: JBossQL, XDocletTags, and Date fields
          Pat Osterday Newbie

          Maybe you could clarify what your date/time problem is with the finder method. I had a similar problem recently because I was using java.sql.Date which doesn't use time information. After switching to java.sql.Timestamp, my problems went away. I'm using JBoss 4 and MySQL 4. The MySQL table field is DATETIME. My finder is based on finding date/times between a start date/time and end date/time and is now working great using Timestamp.

          • 2. Re: JBossQL, XDocletTags, and Date fields
            Hideki Mae Newbie

            Thank you for replying.
            I'm using Oracle9i.
            My problem is that whenever we tried to do a search based on a date field (ex. 1/27/2005). It works if the time was 00:00AM but it will not work if the time was 03:59AM.
            For testing purposes, we set up a dummy database table with a bunch of date fields (Date, TimeStamp). And for my EJB I tried to use java.sql.Timestamp, java.util.Date, java.lang.Long. When we tried to make a straight forward EJB-QL (select object(c) from TestDateSchema as c where c.tstampDate =?1) JBoss had problems parseing it. We also tried to see if it would work for dynamic queries but that didn't work either.
            Next, we thought it might work with JBoss-QL since it supports time information, so we changed the XDoclet tag from @ejb.finder => @jboss.query and this time it could not find the finder method. When we checked the ejb-jar.xml the finder method was empty and jbosscmp-jdbc.xml had the finder method.

            For your database do you have two date fields for start and end date/time? Have you ever tried searching based on a single date field?
            Since we do our search based on one date field we tried doing:
            select object(c) from TestDateSchema as c where c.dummyDate between ?1 and ?2
            where ?1 and ?2 is equal to 1/27/2005 00:00AM and 1/27/2005 23:59PM so we would get data for that date.

            Thanks for all your help.

            • 3. Re: JBossQL, XDocletTags, and Date fields
              Pat Osterday Newbie

              What you are describing sounds exactly like the problem I was having using java.sql.Date - based on finding auctions ending withing a certain date/time. I'm using XDoclet and MyEclipse. My XDoclet finder is:

               findAllEndingAuctions(java.sql.Timestamp endingStartDate, java.sql.Timestamp endingEndDate)"
               query="SELECT OBJECT(a) FROM Auction AS a WHERE a.end_date > ?1 and a.end_date < ?2"

              I haven't done a full testing, but in my rough tests, this is working - including times.