I am using JPA 2.1 in Netbeans to create my entity. If my database has no table then it should create table from entities.
When I deploy and run my enterprise applicati
Anyway, I managed to resolve this problem.
You need to do something using JPA before the table can be created.
For example...
package sessionBean;
import javax.ejb.Stateless;
import entity.userEntity;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@Stateless
public class userSessionBean implements userSessionBeanLocal {
@PersistenceContext
private EntityManager entityManager;
@Override
public userEntity getUser(String userName) {
Query query = entityManager.createQuery("SELECT u FROM userEntity u WHERE u.userName = :inUserName");
query.setParameter("inUserName", userName);
userEntity systemUser = null;
try {
systemUser = (userEntity) query.getSingleResult();
} catch (NoResultException ex) {
ex.printStackTrace();
}
return systemUser;
}
}