Hello,

Trying to use the field conversion:

I have a class "Application" that has an attribute "releaseDate" to store a date (no 
time).
In my database (MS SQL) the type is: datetime
In OJB repository the jdbc-type is: DATE
In my java code I use the class java.util.Date

I added the line below in OJB repository:
conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"

But this produces an error:

[DEFAULT] ERROR: Error in operation [set] of object [PersistentFieldPropertyImpl], 
java.lang.IllegalArgumentException
[DEFAULT] ERROR: Declaring class [com.itservices.woc.data.Application]
[DEFAULT] ERROR: Property Name [releaseDate]
[DEFAULT] ERROR: Property Type [java.sql.Date]
[DEFAULT] ERROR: anObject was class [com.itservices.woc.data.Application]
[DEFAULT] ERROR: aValue was class [java.util.Date]
org.apache.ojb.broker.PersistenceBrokerException: Unable to build object instance 
:class com.itservices.woc.data.Application
        at 
org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(Unknown 
Source)
        at 
org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(Unknown Source)
        at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown 
Source)
        at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
        etc...

Could you help me?
Thanks
Sylvain

> -----Message d'origine-----
> De: Mahler Thomas [mailto:[EMAIL PROTECTED]
> Date: lundi, 17. novembre 2003 11:57
> �: 'OJB Users List'
> Objet: RE: Problem persisting dates
> 
> 
> Yes! FieldConversions are a very old feature.
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]
> > Sent: Monday, November 17, 2003 10:37 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: Problem persisting dates
> > 
> > 
> > Hello,
> > 
> > Is the "conversion=" mechanism works with OJB 0.9.5?
> > 
> > Thanks
> > Sylvain
> > 
> > > -----Message d'origine-----
> > > De: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED]
> > > Date: vendredi, 14. novembre 2003 18:05
> > > �: OJB Users List
> > > Objet: RE: Problem persisting dates
> > > 
> > > 
> > > Hi Carl,
> > > 
> > > java.sql.Date represents a date only, not a date/time.  
> The database
> > > should be a datetime field, the JDBC type should be 
> > TIMESTAMP and you
> > > must use a conversion field to convert to java.util.Date.
> > > 
> > > This is an extract from one of my repository.xml files.
> > > 
> > > <field-descriptor
> > >     name="updated"
> > >     column="Updated"
> > >     jdbc-type="TIMESTAMP"
> > >  
> > > conversion="org.apache.ojb.broker.accesslayer.conversions.Java
> > > Date2SqlTi
> > > mestampFieldConversion"
> > >   />
> > > 
> > > Wally
> > > 
> > > -----Original Message-----
> > > From: Boyes, Carl [mailto:[EMAIL PROTECTED] 
> > > Sent: Friday, November 14, 2003 11:01 AM
> > > To: OJB Users List (E-mail)
> > > Subject: Problem persisting dates
> > > 
> > > 
> > > Hi all,
> > > 
> > > I have an object that has a java.util.Date attribute.  When 
> > persisting
> > > this date, the time portion is stripped. Although dates 
> > with times are
> > > successfully retrieved from the database.
> > > 
> > > I've tried using
> > > org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDate
> > > FieldConve
> > > rsio
> > > n without success.
> > > 
> > > I've also tried modifying the jdbc-type in the sql repository to
> > > TIMESTAMP and using
> > > org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTime
> > > stampField
> > > Conv
> > > ersion, but this made no difference.
> > > 
> > > I'm using MS SQLServer, the current attribute mapping is:
> > > 
> > >   <field-descriptor name="actionDueDate" column="ActionDueDate"
> > > jdbc-type="DATE"
> > >   
> > > conversion="org.apache.ojb.broker.accesslayer.conversions.Java
> > > Date2SqlDa
> > > teFi
> > > eldConversion" />
> > > 
> > > I've looked through the archives and have not found a 
> solution to my
> > > problem, I'm sure I'm missing something obvious!
> > > 
> > > Regards,
> > > 
> > > Carl.
> > > 
> > > The contents of this email are confidential to the intended 
> > > recipient at
> > > the email address to which it has been addressed.  It may not be
> > > disclosed to or used by anyone other than this addressee, nor 
> > > may it be
> > > copied in any way. If received in error, please contact 
> > DLA, a UK law
> > > firm, (http://www.dla.com/) on +44 (0) 8700 111111 quoting 
> > the name of
> > > the sender and the addressee and then delete it from your system.
> > >  
> > > Please note that neither DLA nor the sender accepts any 
> > responsibility
> > > for viruses and it is your responsibility to scan the email and
> > > attachments (if any).  No contracts may be concluded on 
> > > behalf of DLA by
> > > means of email communications.
> > > 
> > > A list of the names of the partners of DLA (who are either 
> > > solicitors or
> > > registered foreign lawyers) and their qualifications is 
> > available for
> > > inspection at 3 Noble Street, London, EC2V 7EE, UK.
> > > 
> > > Regulated by the Law Society.
> > > 
> > > 
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > 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]
> > 
> 
> 
> ---------------------------------------------------------------------
> 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