Re: [JBoss-dev] java.util.Date in PostgreSQL DB

2002-02-12 Thread David Budworth


Hmm, weird.  Because I have actually used Date before, and had the time
dropped off.

Maybe it has something to do with the JDBC drivers conversion of
java.util.Date -> jdbc type DATE -> SQL type DATE?

Ohwell, it works as timestamp, so I won't worry about it for now.

Thanks for the info,

-David

On Tue, 12 Feb 2002, Victor Langelo wrote:

> David Budworth wrote:
> 
> >
> >Or does PostgreSQL DATE/TIMESTAMP exactly the same?  I know oracle will
> >drop the time portion if the column type is DATE.
> >
> >-David
> >
> Actually Oracle will not drop the time protion if the column type is 
> DATE. The following is from the Oracle 8 manual. Oracle 7 says 
> essentially the same thing.
> 
>The DATE datatype stores date and time information. Although date
>and time information can be represented in both CHAR and NUMBER
>datatypes, the DATE datatype has special associated properties. For
>each DATE value, Oracle stores the following information: century,
>year, month, day, hour, minute, and second.
> 
> You need to use TRUNC(date) in order to remove the time portion (or more 
> accurately set it to 0).
> 
> --Victor
> 

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] java.util.Date in PostgreSQL DB

2002-02-12 Thread Victor Langelo



David Budworth wrote:
[EMAIL PROTECTED]">
  Or does PostgreSQL DATE/TIMESTAMP exactly the same?  I know oracle willdrop the time portion if the column type is DATE.-David
  
Actually Oracle will not drop the time protion if the column type
is DATE. The following is from the Oracle 8 manual. Oracle 7 says essentially
the same thing.
   The DATE datatype stores date and time information. Although 
date and time information can be represented in both CHAR and NUMBER datatypes, 
the DATE datatype has special associated properties. For each DATE value, 
Oracle stores the following information: century, year, month, day, hour, 
minute, and second. 

You need to use TRUNC(date) in order to remove the time portion (or more
accurately set it to 0).

--Victor

  [EMAIL PROTECTED]">




Re: [JBoss-dev] java.util.Date in PostgreSQL DB

2002-02-12 Thread Dain Sundstrom

Don't worry, I already set it to TIMESTAMP.

I am a little put off by Adam changing the default database mapping in 
his deb package.  It is his choice to do this, but I will recommend to 
everyone that they don't use the deb package for this reason.

-dain


David Budworth wrote:

> The problem here is that java.util.Date holds an actualy time/date.
> 
> If you don't map it to TIMESTAMP, then you have a dataloss.
> 
> If you want a real SQL DATE field, then use java.sql.Date (which is
> a java.util.Date with the time suppressed)
> 
> I think it would be bad policy to make the default data storage
> mechanism lose data upon storage.  Think about:
> 
> Date d = new Date();
> 
> ejb = Home.create(d);
> if (ejb.getDate().equals(d))// this is true
>doSomething();
> else
>doSomethingElse();
> 
> ejb = Home.find(PKOFEJB);
> if (ejb.getDate().equals(d))// no longer true since you dropped time
>doSomething();
> else
>doSomethingElse();
> 
> So you would, in effect, be breaking application logic.  
> 
> The user would expect both .equals() to be true.
> 
> Or does PostgreSQL DATE/TIMESTAMP exactly the same?  I know oracle will
> drop the time portion if the column type is DATE.
> 
> -David
> 
> 
> On Tue, 12 Feb 2002, Adam Heath wrote:
> 
> 
>>On Tue, 12 Feb 2002, Dain Sundstrom wrote:
>>
>>
>>>This is for anyone who knows Postgres out there,
>>>
>>>There is a patch at sf that suggest adding the following mapping:
>>>
>>>
>>>   java.util.Date
>>>   TIMESTAMP
>>>   TIMESTAMP
>>>
>>>
>>>There is currently no mapping for java.util.Date, but there is a mapping
>>>for java.sql.Date, which is:
>>>
>>>
>>>java.sql.Date
>>>DATE
>>>DATE
>>>
>>>
>>I prefer the latter.  My reasoning, is that if java.util.Date is mapped to
>>TIMESTAMP, then how does someone make a DATE in the database?
>>
>>They could use java.sql.Timestamp to accomplish that.
>>
>>This is what I have done for my debian packages.
>>
>>
> 
> ___
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
> 



___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] java.util.Date in PostgreSQL DB

2002-02-12 Thread David Budworth

The problem here is that java.util.Date holds an actualy time/date.

If you don't map it to TIMESTAMP, then you have a dataloss.

If you want a real SQL DATE field, then use java.sql.Date (which is
a java.util.Date with the time suppressed)

I think it would be bad policy to make the default data storage
mechanism lose data upon storage.  Think about:

Date d = new Date();

ejb = Home.create(d);
if (ejb.getDate().equals(d))// this is true
   doSomething();
else
   doSomethingElse();

ejb = Home.find(PKOFEJB);
if (ejb.getDate().equals(d))// no longer true since you dropped time
   doSomething();
else
   doSomethingElse();

So you would, in effect, be breaking application logic.  

The user would expect both .equals() to be true.

Or does PostgreSQL DATE/TIMESTAMP exactly the same?  I know oracle will
drop the time portion if the column type is DATE.

-David


On Tue, 12 Feb 2002, Adam Heath wrote:

> On Tue, 12 Feb 2002, Dain Sundstrom wrote:
> 
> > This is for anyone who knows Postgres out there,
> >
> > There is a patch at sf that suggest adding the following mapping:
> >
> > 
> >java.util.Date
> >TIMESTAMP
> >TIMESTAMP
> > 
> >
> > There is currently no mapping for java.util.Date, but there is a mapping
> > for java.sql.Date, which is:
> >
> > 
> > java.sql.Date
> > DATE
> > DATE
> > 
> 
> I prefer the latter.  My reasoning, is that if java.util.Date is mapped to
> TIMESTAMP, then how does someone make a DATE in the database?
> 
> They could use java.sql.Timestamp to accomplish that.
> 
> This is what I have done for my debian packages.
> 

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] java.util.Date in PostgreSQL DB

2002-02-12 Thread Adam Heath

On Tue, 12 Feb 2002, Dain Sundstrom wrote:

> This is for anyone who knows Postgres out there,
>
> There is a patch at sf that suggest adding the following mapping:
>
> 
>java.util.Date
>TIMESTAMP
>TIMESTAMP
> 
>
> There is currently no mapping for java.util.Date, but there is a mapping
> for java.sql.Date, which is:
>
> 
> java.sql.Date
> DATE
> DATE
> 

I prefer the latter.  My reasoning, is that if java.util.Date is mapped to
TIMESTAMP, then how does someone make a DATE in the database?

They could use java.sql.Timestamp to accomplish that.

This is what I have done for my debian packages.


___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] java.util.Date in PostgreSQL DB

2002-02-11 Thread Dain Sundstrom

This is for anyone who knows Postgres out there,

There is a patch at sf that suggest adding the following mapping:


   java.util.Date
   TIMESTAMP
   TIMESTAMP


There is currently no mapping for java.util.Date, but there is a mapping 
for java.sql.Date, which is:


java.sql.Date
DATE
DATE


Which is best for the default?

-dain


___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development