Skip to main content

Getting EntityManager using Java Persistence API

1 reply [Last post]
satishpolasi
Offline
Joined: 2006-09-07

Hi,

I'm new to Java Persistence API,
My persistence.xml file looks like this

?xml version="1.0" encoding="UTF-8"?>

javax.persistence.Persistence

I'm getting the EntityManagerFactory like this

public UserCredientials(){
EntityManagerFactory emf = Persistence.createEntityManagerFactory("b2busr");
EntityManager em = emf.createEntityManager();
this.setEntityManager(em);
}
private EntityManager _entityManager;
public EntityManager getEntityManager()
{
return _entityManager;
}
public void setEntityManager(EntityManager entityManager)
{
_entityManager = entityManager;
}

The error is javax.persistence.PersistenceException: No Persistence provider for EntityManager named b2busr

Please help me out to get the EntityManager object.

Thanks in advance
satish

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ss141213
Offline
Joined: 2005-03-30

javax.persistence.Persistence is not a persistence provider. You need to use oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider as provider. For details, refer to https://glassfish.dev.java.net/javaee5/persistence/persistence_faq.html#2

Thanks,
Sahoo