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 "Sergey V. Oudaltsov" <se...@clients.ie> on 2003/11/18 22:42:41 UTC

Primary key/sequence for MS SQL server

Hello all

I am trying to use OJB and find it really comfortable. But there are 
some things still hard to understand.

I am trying to work with some very simple table (in Microsoft SQL) 
having the primary ID as INTEGER. As a SequenceManager, I use HiLo 
implementation. I do everything as requested - but the manager fails 
miserably on new object creation. First, I thought is misses OJB_HL_SEQ 
table - well, I created it manually (taken the script from tests). Then 
I turned the SQL logging on (to DEBUG level) and see that it is trying 
to do two SELECTs from OJB_HL_SEQ (by the tablename and fieldname) and 
then - one INSERT. And it failes on this INSERT - I get the error about 
inability to get the Identity for the new object. Is there any way I 
could get more information about the problem? What could this be?

More general question - what kind of SequenceManager people use for MS 
SQL server in clustered environment. As an application server we are 
going to use Tomcat and JBoss (and take DataSource from them as a 
connection pool).

Thanks for any hints,

Sergey

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


Re: Primary key/sequence for MS SQL server

Posted by "Sergey V. Oudaltsov" <se...@clients.ie>.
Just in case anyone interested.

I found the matter of problem. It is between OJB and JDBC driver (I used
jtds driver). The thing is that HiLo seq. manager using the type java.
lang.Long as a value for the unique id. And in the table it is INTEGER
(and in repository_internal.xml as well). So this stupid jtds driver
throws ClassCastException trying to case Long to Integer. I realize -
this is mostly the driver's problem. But probably OJB should consider
using Integer instead of Long (or at least declaring field as BIGINT in
repository_internal.xml)?

Regards,

-- 
Sergey


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