tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnieto <gamma_...@yahoo.com>
Subject Re: Date format for Column Conversion, String on Bean, Date on Database
Date Tue, 14 Jun 2011 06:48:01 GMT
Hi,

The trouble is, in our bean the attribute already is in String format.
Something else is doing all the conversion, I'm not sure if OpenEJB or
OpenJPA is just reading the date as a string. This could cause problems for
us when we're reading from a different database wherein there is a different
default format for the database. 

What I'm wondering is if there is a configuration, annotation or setting
somewhere where I can dictate how the conversion from Date to String on the
query is done (before it reaches the bean). Or if I can somehow update the
behavior of the retrieval when it sees that the column is a Date, and do
some custom behavior.

Thanks!





Romain Manni-Bucau wrote:
> 
> Hi,
> 
> i think it is more a database issue than a software one.
> 
> you can still use a simple date format in java to have this format (in
> your
> getter for example) but it will always depend on the database value and
> i'm
> not sure you'll have exactly what you need.
> 
> - Romain
> 
> 2011/6/14 rnieto &lt;gamma_ass@yahoo.com&gt;
> 
>> I'd like to ask if there's a way to specify the behavior on how it would
>> handle querying Date columns and converting them to a String attribute on
>> the java bean. (We're using OpenEJB 3.1.4, tomcat 6, JTDS and MS SQL
>> Server
>> 2008).
>>
>> History, why we're using String:
>> Previously we were having problems with OpenEJB 3.1, we were just
>> querying
>> for a row of data on the database. Out set-up involved the table being
>> able
>> to be inserted into, queried, but there was this date field that can
>> never
>> be updated.
>>
>> Think of it like this: In today's systems if you're doing trial version
>> software, there's the First Installed date. A date which cannot be
>> changed
>> or updated as any user can update that field making the software run
>> longer
>> instead of 30 days. The user can query and look when he first installed
>> it,
>> and other information related to the user.
>>
>> The problem appeared that after querying for the row, somewhere within
>> OpenEJB 3.1 an update was also being issued to the same row we just
>> queried.
>> Since it isn't allowed to update that specific column, we were getting
>> exceptions about being unable to issue an update. The odd thing, after
>> other
>> people ran SQL Server Profiler, they saw that it was issuing an update
>> right
>> after the select statement, wherein the data is still 100% the same. When
>> we
>> changed the data type of the column on the Java bean to String, only the
>> select statement is now being issued.
>>
>> Now we're tasked to locate on how to control the query wherein it should
>> specifically convert the datetime into a certain format, for our case
>> (YYYY-MM-DD HH:MM:SS.SSS). This is to guarantee that the format would
>> always
>> be the same to whatever deployed database it uses.
>>
>> I've searched high and low, and I'm not sure whether this is really a
>> configurable item within OpenEJB or OpenJPA.
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/Date-format-for-Column-Conversion-String-on-Bean-Date-on-Database-tp3595707p3595707.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
> 


--
View this message in context: http://openejb.979440.n4.nabble.com/Date-format-for-Column-Conversion-String-on-Bean-Date-on-Database-tp3595707p3595772.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message