Have you tried to use 

org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimestampFieldConversion

as conversion in XML?

Works for me like a charm.

Best regards,

Edson Richter


----- Original Message ----- 
  From: Raoul Markus 
  To: OJB Users List 
  Sent: Monday, September 01, 2003 3:47 PM
  Subject: newbie q: Criteria for java.util.Date


  Hi,

  I tried the following code, but this query didn't return any hits:

  public static Collection getSessionsOfDay(DBConnector pDbconnector,Date 
  pDateHeld, String pUser) {
  ...
  tCrit.addEqualTo("DATE_HELD", pDateHeld);
  ...
  Query tQuery = new QueryByCriteria(SDBSession.class, tCrit);
  }





  and I had to replace it by the following (which works, but is no good):


  public static Collection getSessionsOfDay(DBConnector pDbconnector,Date 
  pDateHeld, String pUser) {
  ...
  // TODO: this date operations  are not nice...
  Calendar tCal = Calendar.getInstance();
  tCal.setTime(pDateHeld);
  // make a string like "2003-8-29", which is recognized by mysql
  String tDateStr = "" + tCal.get(Calendar.YEAR) + "-" + 
  (1+tCal.get(Calendar.MONTH)) + "-" + tCal.get(Calendar.DAY_OF_MONTH);  
  tCrit.addEqualTo("DATE_HELD", tDateStr);
  ...
  Query tQuery = new QueryByCriteria(SDBSession.class, tCrit);


  in mysql (3.23.55-log), the column is defined as DATE and holds to my opinion 
  only the day (not the time). the java.util.Date of course has the exact time, 
  maybe this causes the null result?

  But with the tDateStr I am no longer independend of the db (i.e. which date 
  strings it recognizes). 

  any tips, thoughts?

  Thanks in advance.

  -- 
  Raoul Markus
  PGP key available from servers


  ---------------------------------------------------------------------
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]



  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.514 / Virus Database: 312 - Release Date: 28/8/2003

Reply via email to