Chris Tragas wrote:
> Hi.
>
> I've been on this problem for days now and I'm crying out for some help.
>
> What I am trying to achive is to have a cmp bean that is mapped to a
> database table in which the primary key is also an identity column (ie self
> incrementing) I've read a lot of the queries and answers that have been sent
> but I havent found a solution that suffices.
>
> Versions i'm using are: JBoss 2.2.2 with Tomcat 3.2.1 and SQL Server 7 on an
> NT4 server.
>
> What I'm trying to achieve is when i create a new CustomerDetails Bean via
> the Home.create method I want the ejbCreate method to look up the database
> to find the max(company_id) and assign the primary key value of the new
> CustomerDetails Bean i'm trying to create to max(company_id) + 1;
Unfortunately, CMP and identity columns don't work very well together.
Is there any way you can use a sequence facility? If so, you can simply
get the sequence value in your ejbCreate and set it into your primary
key field
>
> I successfully deploy the bean (sometimes, I wont even begin to explain the
> inconsistencies I've been experiencing with Jboss deployment - for instance.
> it spits out error messages regarding method types that don't even exist- is
> there a caching issue here???);
Is it possible that it's picking up old versions of your code, or
different deployment descriptors than are in your jar? What error
messages are you getting exactly?
> Then I have a jsp client that access the cmp bean CustomerDetails. When I
> reference home.create() method the container management tries to insert into
> the database a row with the column value of the primary key as null;
> I assumed that when calling the home.create() method, the corresponding
> ejbCreate method in the remote bean CustomerDetailsEJB would be called; but
> it doesnt appear to be getting there and I have no way of telling;
It _should_ be getting there. Put some trace statements in there or run
under a debugger to be sure. I'm not sure you're getting your database
connection. However, the way you've written this the best that will
happen is that the CMP stuff will get a key violation error when it
tries to insert a row with the id that you just grabbed out of there.
>
> HELP? Please? Anyone? Things are growing out of my forehead that shouldnt be
> as a result of this "hic-up";
Either don't use identity columns, or don't use CMP. Sorry, but that's
the best answer I can give at this point.
-danch
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user