Hi

The mistake being made is that a finder method takes the information (read
SELECT) from the database and calls the setters on your Entity bean to
populate it. It then returns a reference to this new object. The create
methods actually CREATES (read INSERT) the information into the database.

These are two diffrent functions and behind the scenes call totally diffrent
'ejb' methods.

The finder method 'loads' information and the creator method 'creates'
information.

What may be confusing you is that the findByPrimaryKey(..) has to CREATE the
bean in the container that will be returned in your method, but, this step
DOES NOT refer to the ejbCreate() method you are talking about, it is
actually the ejbLoad(..) method.

So in summary:
findByXYZ(..) -> SELECT FROM DB, populate an instance of the Entity [calling
ejbLoad(..) method), return reference.
create(..) -> INSERT INTO DB, (Calling the ejbCreate(..) method). Return
reference..

Hope this helps.

-----Message d'origine-----
De : A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]De la part de JavaSoft
Envoy� : Wednesday, March 27, 2002 2:43 AM
� : [EMAIL PROTECTED]
Objet : Re: EntityBean


oh .. oki maybe i explained in wrong way.
I  know you dont call method directly into entity bean :o). You have to call
methods in the interfaces where entity bean implements it.
I just dont get it when the container creates the entity bean object if the
data in the table already exist, is it when you up the application or when
container invokes ejbCreate( ) or when container invokes
ejbFindByPrimaryKey(). But let me read the url that you gave to me ...
thanks anyway.

===
thx,
H`L
----- Original Message -----
From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 27, 2002 3:12 PM
Subject: Re: EntityBean


> > No .. its not what i mean ..
> > I am confused .. when an object of an Entity Bean will be constructed ?
when
> > i invoke ejbCreate() or ejbFindByPrimaryKey() or what ?
> >
> > Let say .. you want to update a record with the enity bean after you up
your
> > Enterprise App. You will need an entity bean object that represents the
> > record right ? and if the object is already in JVM, you call
> > ejbFindByPrimaryKey() to get the reference, after that you can call any
> > methods inside the object.
>
> you dont call _any_ methods on the bean.  You call methods on its home
interface, and its component interfaces.  So you call
>
>     myBeanHome.findByPrimaryKey(...)
>
> the container then calls ejbFindByPRimaryKey(...)
>
> > If The object of entity bean isnt in JVM yet, how can i create the
object ?
> > From all my understanding, ejbCreate() will create an entity object and
add
> > a record into database. But how about if the data already in database
and i
> > just wanna create the object that represents the record data ?
>
> it doesn't matter if its in the jvm or not... the container deals with
that.
>
> you should get a good ejb book, or read one online (see
http://www.theserverside.com) because this is basic ejb stuff, that you'd
> learn a lot quicker from a book... also you might miss things learning
this way.
>
> hth
> dim
>
> >
> > ===
> > ===
> > thx,
> > a Java Addicted
> >
> > ----- Original Message -----
> > From: "Ashwani Kalra" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, March 27, 2002 2:50 PM
> > Subject: Re: EntityBean
> >
> >
> > > You are confusing when ejbCreate is called. It is called when you
invoke
> > one
> > > of the create methods in the home interface. ejbFindByPrimaryKey is
called
> > > for getting the existing records.
> > >
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > Thanks
> > > Ashwani Kalra
> > > Sr. Mem. Dev. Staff
> > > Aithent Technologies
> > > http://www.geocities.com/ashwani_kalra/
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >
> > >
> > > -----Original Message-----
> > > From: A mailing list for Enterprise JavaBeans development
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of JavaSoft
> > > Sent: Wednesday, March 27, 2002 12:16 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: EntityBean
> > >
> > >
> > > Hi guys
> > > I am confused about ejbFindByPrimaryKey() method. It said that the
method
> > > will return reference to the object of the Primary Key.
> > >
> > > My question is when Entity Bean Object will be created ? if the answer
is
> > > when invoking ejbCreate(), how about if in the table, there're some
datas
> > > already before My Enterprise App. up ? I dont think i need to invoke
> > > ejbCreate() to create object of a record data that already exist in
the
> > > table when I up my Enterprise Application right ?
> > > And the datas in the table could be from the admin enter it directly
to
> > the
> > > table or migrate from another database.
> > >
> > > So what i will get if i invoke ejbFindByPrimaryKey() without invoking
> > > ejbCreate() first ?
> > >
> > > ===
> > > thx,
> > > a Java Addicted
> > >
> > >
> >
===========================================================================
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> > body
> > > of the message "signoff EJB-INTEREST".  For general help, send email
to
> > > [EMAIL PROTECTED] and include in the body of the message "help".
> > >
> > >
> >
===========================================================================
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> > body
> > > of the message "signoff EJB-INTEREST".  For general help, send email
to
> > > [EMAIL PROTECTED] and include in the body of the message "help".
> > >
> >
> >
===========================================================================
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> > of the message "signoff EJB-INTEREST".  For general help, send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
> >
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to