You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Geigl Maximilian, R235" <Ge...@akdb.de> on 2003/07/15 20:54:42 UTC

[MAPPING] MS SQL Server and DATETIME conversion

Hello,

i use OJB 1.0 rc2, MS SQL Server 2000 on WIN2K with the MS JDBC driver and have a date field:

    <field-descriptor
         name="edatum"
         column="EDATUM"
         jdbc-type="DATE"
    />

with the corresponding data type DATETIME in the datebase, which can stores date and time information in one field.
When i issue an INSERT that only has date information (like '2003-03-04') and execute a subsequent SELECT with a WHERE clause like field='2003-03-04' i do not get any result (all through OJB naturally).

As far as i found out for the leading INSERT the (not given) time part is generated as 12:00:00.000, the SELECT looks for a DATETIME value with the time part like 00:00:00.000. and does not find any rows.

Can somebody explain to me, how the generation of time parts is working or if i can configure this. Is it happening inside OJB (i don't think as is examined the p6spy log), the sql server or inside the jdbc driver (which i suspect, because the same example in query analyzer works).

What can i do to work around this problem? Thank you for any suggestions.

Regards
Max




MS SQL Server Sequence Solution

Posted by Cory L Hubert <ch...@alloy.com>.
	My Dev group is planning on implementing the MSSQL sequence solution
describe here
http://db.apache.org/ojb/sequencemanager.html#Oracle-style%20sequencing

	One of our developers raised a concern about using this method within
transactions.   What happens during a rollback?

	For example.   One process gets the next val. Let's say it returns 10, and
another process get's 11.   What happens to the OJB_NEXT_VAL table if the
transaction (the one that got 10) was rolled back?


	Also on a side note. Is there anyone developing a MS SQL Server Sequencer?


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: [MAPPING] MS SQL Server and DATETIME conversion

Posted by Edson Carlos Ericksson Richter <ed...@mgrinformatica.com.br>.
I'm not sure, but I think you need a conversion:

    <field-descriptor
         name="edatum"

conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimest
ampFieldConversion"
         column="EDATUM"
         jdbc-type="DATE"
    />

I've used this with SapDB and MS SQL 2K in my apps and worked fine. You
should remember that java.sql.Date have different treatment than
java.util.Date.

Of course, you should guarantee that you are not capturing the time part
when inserting data... I'm using a function to truncate the time part in my
apps.

Best regards,

Edson Richter

----- Original Message ----- 
From: "Geigl Maximilian, R235" <Ge...@akdb.de>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, July 15, 2003 3:54 PM
Subject: [MAPPING] MS SQL Server and DATETIME conversion


Hello,

i use OJB 1.0 rc2, MS SQL Server 2000 on WIN2K with the MS JDBC driver and
have a date field:

    <field-descriptor
         name="edatum"
         column="EDATUM"
         jdbc-type="DATE"
    />

with the corresponding data type DATETIME in the datebase, which can stores
date and time information in one field.
When i issue an INSERT that only has date information (like '2003-03-04')
and execute a subsequent SELECT with a WHERE clause like field='2003-03-04'
i do not get any result (all through OJB naturally).

As far as i found out for the leading INSERT the (not given) time part is
generated as 12:00:00.000, the SELECT looks for a DATETIME value with the
time part like 00:00:00.000. and does not find any rows.

Can somebody explain to me, how the generation of time parts is working or
if i can configure this. Is it happening inside OJB (i don't think as is
examined the p6spy log), the sql server or inside the jdbc driver (which i
suspect, because the same example in query analyzer works).

What can i do to work around this problem? Thank you for any suggestions.

Regards
Max





---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org