Shayne Hughes wrote:
>
> I'd be interested to hear what others think of this method of using MSSQL's
> autoincrement type as PK. I have tried this and it seems to work in simple
> tests. Yeah it's not portable and probably breaks several rules.
>
> For this table...
> CREATE TABLE [dbo].[Lab] (
> [LabID] [int] IDENTITY (1, 1) NOT NULL ,
> [Name] [varchar] (255) NOT NULL ,
> [LastUpdate] [datetime] NOT NULL
> )
>
> I have an CMP EJB with the following in the orion-ejb-jar.xml...
> <finder-method query="insert into Lab (Name,LastUpdate) values
> ($1,GetDate()); select LabID,Name,LastUpdate from Lab where
> LabID=@@IDENTITY" partial="false">
> <method>
> <ejb-name>Lab</ejb-name>
> <method-name>findNew</method-name>
> <method-params>
> <method-param>java.lang.String</method-param>
> </method-params>
> </method>
> </finder-method>
>
> So, you never create a new bean in the normal CMP way, but if you need a new
> one, you call this finder which creates a new one and finds it.
This is a really cool workaround ;-)
sven
--
======================================================================================
Sven E. van 't Veer
http://www.cachoeiro.net
Java Developer [EMAIL PROTECTED]
======================================================================================