I am confused with the EJB3 persistence.xml file. Below I have mentioned two scenarios for saving the Student object.One with Persistence.xml and one without the persistence.xml file. I. We can do the persistence with the below code.It means we are using the EntityManager reference for saving. private EntityManager manager; public EntityManager getManager() { return manager; } @PersistenceContext public void setManager(EntityManager manager) { this.manager = manager; } public void saveStudent(Student stu) { getManager().persist(stu); } ***************************************************************** II. EntityManagerFactory emf=Persistence.createEntityManagerFactory("SampleEJBPU");// SampleEJBPU defined in persistence.xml file. EntityManager em=emf.createEntityManager(); public void saveStudent(Student stu) { em.persist(stu); } Persistence.xml file. <!--?xml version="1.0" encoding="UTF-8"?--> org.hibernate.ejb.HibernatePersistence java:/MyDS com.my.entity.Student So save process can happen with EJB3 in two ways, with persistence.xml file or without persistence.xml file. My question is 1) In the first scenario without persistence.xml file, with Entitymanager we can save the Student object. But in the second scenario we are defining the persistence.xml file and mention the Hibernate connection details explicitly and calling the persistence unit name in the bean. Why we use persistence.xml file, as we can do without persistence.xml file ?