Hi,

Have you try to use TIMESTAMP for your jdbc-type,
you can try like this :

<field-descriptor id="18"
        name="d8cleh"
        column="D8CLEH"
        jdbc-type="TIMESTAMP"

conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimest
ampFieldConversion"
/>

The class for the conversion is already define in OJB.

Hope that help.

-----Message d'origine-----
De : eric barbe [mailto:[EMAIL PROTECTED]
Envoyé : jeudi 15 janvier 2004 09:22
À : OJB Users List
Objet : RE: Date problem ?


Does somebody have an idea ?

Thanks

Éric

-----Message d'origine-----
De : eric barbe [mailto:[EMAIL PROTECTED]
Envoyé : mercredi 14 janvier 2004 17:44
À : [EMAIL PROTECTED]
Objet : Date problem ?


Hi everybody,

I'm working under Oracle 8i.

In my repository_user.xml, i have amongst other things this class descriptor

<class-descriptor class="Object" table="objects">
   <field-descriptor name="id" column="cid" jdbc-type="INTEGER"
primarykey="true"/>
   <field-descriptor name="begin" column="cbegin" jdbc-type="DATE"
conversion="Calendar2DateFieldConversion"/>
   <field-descriptor name="end" column="cend" jdbc-type="DATE"
conversion="Calendar2DateFieldConversion"/>
</class-descriptor>

where the Calendate2DateFieldConversion looks like following :

/*
 * Created on 19 nov. 2003
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package MyPackage;

import java.sql.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;

import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;

/**
 * @author ghd
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class Calendar2DateFieldConversion implements FieldConversion {
        /**
         * @see FieldConversion#javaToSql(Object)
         */
        public Object javaToSql(Object source)
        {
                if (source instanceof Calendar)
                {
                        return new Date(((Calendar) source).getTimeInMillis());
                }
                else
                {
                        return source;
                }
        }

        /**
         * @see FieldConversion#sqlToJava(Object)
         */
        public Object sqlToJava(Object source)
        {
                if (source instanceof Date)
                {
                        GregorianCalendar cal = new GregorianCalendar();
                        cal.setTimeInMillis(((Date)source).getTime());
                        return cal;
                }
                else
                {
                        return source;
                }
        }
}

my problemn is that the date are stored without the hour informations under
Oracle. It works fine with SQL Server. :-(

Does somebody knows about this problem ?

Regards.

Éric


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



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


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

Reply via email to