An usual process, that could answer you question, is: a) look if the record already exists, if it does, the container will create the object and return the reference to you. If not, the container will throw a FinderException b) if the FinderException was thrown, the record doesn't exists and you can call create or anything else.
Some people do the inverse: a) try to create the record directly. if the record already exists, the container throws a CreateException. If not, the object is created and returned to the client. b) if the CreateException was thrown, the record exists in the database, so you can call findByXXX to obtain the object safely. ----- Original Message ----- From: "JavaSoft" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 27, 2002 4:42 AM Subject: 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".
