Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: EJB & Primary Keys

Re: EJB & Primary Keys

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: 2000/08/03
Message-ID: <3988D27D.F98276B@rationalconcepts.com>#1/1

Sigh, I meant create, not great...tired fingers...

cindy

"C. Ferguson" wrote:

> Why not great a database function that takes as an input parameter of
> the emp_name, and returns the id? See stored procedures and functions.
> Then the bean makes one call to the database via the function...
>
> hth,
> cindy
>
> Chakravarthy KM Nalamotu wrote:
>
> > One of our developers is writing a container
> > managed EJB (entity beans) to insert records
> > into a table. Let's say the table name is
> >
> > emps(emp_id NUMBER(10),
> > emp_name VARCHAR2(10))
> >
> > In the entity bean, they intend to insert just
> > the employee name, and have the primary key
> > generated through a before insert trigger
> > automatically.
> > Now the question becomes how does the entity
> > bean know about the primary key created
> > through the trigger.
> > Right now they have a trigger and pass a 0 for
> > emp_id and triggers generates it's own sequence
> > number before insert.
> > The second insert fails with a duplicate primary key.
> > Looks like the container caches sequence numbers.
> >
> > Programmers are reluctant to clutter the
> > code with JDBC calls to get the sequence
> > number for primary key.
> >
> > Did anyone run into this situation?
> > How does everyone else generate a primary key using
> > entity beans?
> >
> > Your input is greatly appreciated.
> >
> > Thank you,
> > Kittu.
Received on Thu Aug 03 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US