Posts

javax.persistence.PersistenceException: No Persistence provider for EntityManager named employeeEntityManager

Exception: log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations. Version ). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" javax.persistence. PersistenceException : No Persistence      provider for EntityManager named employeeEntityManager  at javax.persistence. Persistence .createEntityManagerFactory( Persistence .java: 55 )  at javax.persistence. Persistence .createEntityManagerFactory( Persistence .java: 33 )  at EmployeeDaoImpl .create( EmployeeDaoImpl .java:21)  at EmployeeDaoImpl .main( EmployeeDaoImpl .java: 25 ) The PersistenceException hierarchy is : ·          java.lang.Object          java.lang.Throwable           java.lang.Exception           java.lang.RuntimeException           javax.persistenc...

Exception Description: Missing descriptor for [class com.Employee]

JPA lifecycle

Image
JPA Entity Lifecycle:

Native Query – How to call native SQL query with JPA

Native Query – How to call native SQL query with JPA The Java Persistence Query Language (JPQL) is that most common using to query data from a database with JPA. It supports a small subset of the SQL queries. JPA has its own query language (i.e. JPQL) but it supports native SQL queries also.  You can create these queries in a very similar way like JPQL queries and they can even return either object or entities. Native queries creation or how to create native queries: To creating a native query is quite simple with JPA. The  EntityManager  interface provides a method called  createNativeQuery  . The createNativeQuery() method returns an implementation of the  Query  interface which is the same as the  createQuery()  method to create a JPQL query. Define the attributes to select statement: Generally many developers use the JPQL to fetch the results/entities. But that’s not the only way you ...