Hi David, (p.s. cc to middlegen-user)
There are two issuses here:
-How to make the default java type for uniqueidentifier be
java.lang.String, and not byte[]
-How to tell Middlegen to always suggest custom PK classes.
I'll explain in more detail...
If a table's primary key consists of only one field, there is
(according to the EJB spec) no need to make your own primary key class
for your EJB. Primary key classes are only needed if the table's
primary key consistes of more than one field, in which case you need a
compound primary key.
Middlegen will therefore by default suggest to use the preferred java
type of the single pk field when the table's pk is only one field. Why?
It makes the code simpler, and might increase the performance slightly
since a wrapper key object around a String won't need to be created.
The JDBC spec suggests allowed and preferred mappings between SQL types
and SQL types. This is shown in one of the png files under
middlegen/doc and implemented in Sql2Java.
In some cases (like yours) the suggested mapping is not good. You
probably want the MSSQL uniqueidentifier type (which your driver
reports as type java.sql.Types.BINARY doesn't it?) to map as default to
a String. I've added that code to the tune method in
MiddlegenPopulator. It's untested (and obviously doesn't work, since
you apparently still get byte[] as preferred type for BINARY). It would
be nice if you could help me.
The other issue is how to make Middlegen always suggest a PK class, no
matter if the pk consists of a single field. I'm not in front of the
code now, so I don't remember exactly where it is. I think it is
somewhere in the Table hierarchy: A method called setSimplePk(boolean)
or something. I can add an option to the cmp20 subtask which lets you
override this, ao that you always get a pk class no matter what.
Here's the deal:
-You verify my code in MiddlegenPopulator (where your name is) and make
sure the suggested type for BINARY is something else than byte[] when
running your driver.
-I implement functionality to override so you always get Pk class.
Deal?
Aslak
----- Original Message -----
From: ***@apcc.com
Date: Thursday, April 25, 2002 4:37 pm
Subject: Re: Fwd: RE: [Middlegen-user] Primary key class
Alright I got it compiling and detecting my driver now. Can you
point me
in the right direction as to were to look for what causes the
Primary Key
class to populate with byte[] I have attached a screen shot.
Were is the
code that determines what the Primary key class should be. It
always comes
up with byte[] I would like for it to be a primary key class.
(Embedded image moved to file: pic04041.pcx)(Embedded image moved
pic03602.pcx)
Thanks david
"David Cowan"
[Middlegen-user] Primary key class
04/25/2002
09:28 AM
Subject: RE: [Middlegen-user] Primary key class
Date: Wed, 24 Apr 2002 23:58:08 +0200
I can't get the latest cvs to build. I get 56 errors. most of
them having
to do with plugin classes.
Sorry, I was a bit quick. If you update, build clean and then
build, it
should be ok...
Aslak
_________________________________________________________________
Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp.