Java Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 306
Number of posts: 629

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Persistence of EJB. Posted by shanthkumar on 29 Sept 2006 at 6:24 AM
Can anybody please tell what is the actual meaning of persistence and how EJB will provide persistence.
Report
Re: Persistence of EJB. Posted by sushant_pate on 17 Oct 2006 at 1:21 AM
Are you talking about Bean Managed Persistence and Container managed Persistence by any chance? is yes read:

There are two methods of designing your entity beans BMP and CMP,

when You are using BMP You need to handle all the Database connections ,retrieval queries etc.

But in case of CMP all you need to do is leave this upto the container to do it( so ur ejbLoad() , ejbStore() methods are left blank), wat u need to do is just take care of all this when you are Deploying the EJB.
Report
Re: Persistence of EJB. Posted by shanthkumar on 17 Oct 2006 at 1:36 AM
Basically how many classes are required to be written when writing any of EJB's?
Which are the classes?

: Are you talking about Bean Managed Persistence and Container managed Persistence by any chance? is yes read:
:
: There are two methods of designing your entity beans BMP and CMP,
:
: when You are using BMP You need to handle all the Database connections ,retrieval queries etc.
:
: But in case of CMP all you need to do is leave this upto the container to do it( so ur ejbLoad() , ejbStore() methods are left blank), wat u need to do is just take care of all this when you are Deploying the EJB.
:

Report
Re: Persistence of EJB. Posted by sushant_pate on 17 Oct 2006 at 2:01 AM
it all depends.. what type of EJB are you building?
You will require to be a little more specific

Essential classes are
1)Bean Class(Session or entity)

interfaces
1) Home interface(local remote)
2) Remote Interface(local remote)

Report
Re: Persistence of EJB. Posted by shanthkumar on 17 Oct 2006 at 2:13 AM
: it all depends.. what type of EJB are you building?
: You will require to be a little more specific
:
: Essential classes are
: 1)Bean Class(Session or entity)
:
: interfaces
: 1) Home interface(local remote)
: 2) Remote Interface(local remote)
:
:

Classes that I must write for a simple EJB?
For session beans?
For Entity beans?
Do I have to write 4 classes or 3 classes?
Report
Re: Persistence of EJB. Posted by sushant_pate on 17 Oct 2006 at 2:24 AM
See dosent matter what type of EJB u r developing
THREE THINGS ARE REQD(on the server side):
1) Bean class
this class implements SessionBean/EntityBean interface again depending on the type of bean you are developing.
2) Home Interface
This is required and has the create() method(ie, life cycle methods)
3)Remote Interface
Contains "declarations" for the bean methods.


Report
Re: Persistence of EJB. Posted by shanthkumar on 17 Oct 2006 at 2:41 AM
: See dosent matter what type of EJB u r developing
: THREE THINGS ARE REQD(on the server side):
: 1) Bean class
: this class implements SessionBean/EntityBean interface again depending on the type of bean you are developing.
: 2) Home Interface
: This is required and has the create() method(ie, life cycle methods)
: 3)Remote Interface
: Contains "declarations" for the bean methods.
:
:
:

Any simple example for all these 3 classes? Like if I have student as my database table what would be the structure of each classes? If possible plz explain. Thanks in advance.
Report
Re: Persistence of EJB. Posted by sushant_pate on 17 Oct 2006 at 3:00 AM
there is only one class and 2 interfaces
I dun knw the exact question you want me to solve but this will help


public class StudentBeanExample implements EntityBean
{


String name; /*say name of the student */
String elective;
int class;
int section;
.........
.........
/* these methods are reqd */
public void ejbCreate(/* can have args here */)
{}
public void ejbLoad()
{
/*perform load operation to update your local variables to
maintain consistency with the DBMS record*/
}
public void ejbStore()
{
/*perform load operation to update your dbms to
maintain consistency with the local variables record*/
}
public void ejbRemove()
{
}
other such methods you need to code
....
//Your own methods go here
*/
}// end of class

then you create a remote interface

public interface Student extends EJBObject
{
/* put in declarations all the methods that ur Bean class
requires leaving out the predefined methods(having the ejb prefix) */
}

then u code your home interface

public interface StudentHome extends EJBHome
{
public void create(/* can have args here */)

}

Now replicate home and remote interfaces so that u have a local and remote for both the interfaces and u are through with it.

Report
Re: Persistence of EJB. Posted by shanthkumar on 30 Oct 2006 at 10:30 PM
As you have told to write 3 classes how about the other three classes?
Local home interface,LocalHome, Local interface.
What does these class contain? What should i write in this?
I have got to know what will be there in

Remote interface, Home interface and EJB classes.



: there is only one class and 2 interfaces
: I dun knw the exact question you want me to solve but this will help
:
:
: public class StudentBeanExample implements EntityBean
: {
:
:
: String name; /*say name of the student */
: String elective;
: int class;
: int section;
: .........
: .........
: /* these methods are reqd */
: public void ejbCreate(/* can have args here */)
: {}
: public void ejbLoad()
: {
: /*perform load operation to update your local variables to
: maintain consistency with the DBMS record*/
: }
: public void ejbStore()
: {
: /*perform load operation to update your dbms to
: maintain consistency with the local variables record*/
: }
: public void ejbRemove()
: {
: }
: other such methods you need to code
: ....
: //Your own methods go here
: */
: }// end of class
:
: then you create a remote interface
:
: public interface Student extends EJBObject
: {
: /* put in declarations all the methods that ur Bean class
: requires leaving out the predefined methods(having the ejb prefix) */
: }
:
: then u code your home interface
:
: public interface StudentHome extends EJBHome
: {
: public void create(/* can have args here */)
:
: }
:
: Now replicate home and remote interfaces so that u have a local and remote for both the interfaces and u are through with it.
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.