Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
EJB create method 
 

In this tutorial we are describing you about the EJB create method. The create() method is used for creating the EJBean.

 

EJB create method

                         

In this tutorial we are describing you about the EJB create method. The create() method is used for creating the EJBean. The other methods which are used in the program given below ..

 private EntityManager em:-Defines an Interface instance. The interface Entity manager is associated with the persistence context.

em.persist(newsEntity):-This method makes an entity instance managed and persistent.

em.merge(newsEntity):-This method merge the state of the given entity into the current persistence context.

em.remove(em.merge(newsEntity)):-By using this method we can remove the entity instance.

 em.find(ejb.NewsEntity.class, id):-This methods find the entity instance by the primary key. Here primary key is id.

package ejb;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;


@Stateless
public class NewsEntityFacade implements NewsEntityFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(NewsEntity newsEntity) {
        em.persist(newsEntity);
    }

    public void edit(NewsEntity newsEntity) {
        em.merge(newsEntity);
    }

    public void remove(NewsEntity newsEntity) {
        em.remove(em.merge(newsEntity));
            }

    public NewsEntity find(Object id) {
        return em.find(ejb.NewsEntity.class, id);
    }

    public List findAll() {
        return em.createQuery("select object(o) from NewsEntity as o").getResultList();
    }

}

Download source code

                         
» View all related tutorials
Related Tags: c database data application io find ejb this app simple tab example to base exam ssi e eps li im

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.