-
1. Re: JBossQL, XDocletTags, and Date fields
osterday Feb 15, 2005 9:50 AM (in response to hmae)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
hmae Feb 15, 2005 10:14 AM (in response to hmae)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
osterday Feb 15, 2005 11:22 AM (in response to hmae)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:
@ejb.finder signature="java.util.Collection 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.