Comment

jpababy
JPA erro,
October 1, 2010 at 2:58 PM

I am a JPA starter and am getting below error while running simple JPA example,could some able to help out ?

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" java.lang.AbstractMethodError: org.slf4j.impl.Log4jLoggerAdapter.trace(Ljava/lang/String;Ljava/lang/Object;)V
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:313)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at JPASetFirstResult.main(JPASetFirstResult.java:53)


JPASetFirstResult.java
----------------------------------------------------------------------------
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
public class JPASetFirstResult {
public static void main(String[] args) {
EntityManagerFactory emf=null;
EntityManager em=null;
try{
emf=Persistence.createEntityManagerFactory("test");
em=emf.createEntityManager();
EntityTransaction entr=em.getTransaction();
entr.begin();
Query query=em.createQuery("SELECT st FROM Student st");
query.setFirstResult(2);
List stuList=query.getResultList();
Iterator stuIterator=stuList.iterator();
while(stuIterator.hasNext()){
Student st=(Student)stuIterator.next();
System.out.print("sname:"+st.getSname());
System.out.print("sroll:"+st.getSroll());
System.out.print("scourse:"+st.getSname());
System.out.println();
}
entr.commit();
}catch(Exception e){
System.out.println("Exception ==> "+e);
}finally{
if(em != null)
em.close();
}
}
}

--------------------------------------------------------------------------
persistence.xml.....Inside "META-INF"...folder
------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>Student</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"></property>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></property>
<property name="hibernate.show_sql" value="true"></property>
<property name="hibernate.connection.username" value="test"></property>
<property name="hibernate.connection.password" value="test"></property>
<property name="hibernate.connection.url" value="jdbc:mysql:///test"></property>
</properties>
</persistence-unit>
</persistence>
------------------------------------------------------------
Student.java as below
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import java.io.Serializable;
@Entity
@Table(name="student")
public class Student implements Serializable {
@Id
@GeneratedValue
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="sname", length=100,nullable=false)
private String sname;
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
@Column(name="sroll",nullable=false)
private int sroll;
public int getSroll() {
return sroll;
}
public void setSroll(int sroll) {
this.sroll = sroll;
}
@Column(name="scourse",length=10,nullable=false)
private String scourse;
public String getScourse() {
return scourse;
}
public void setScourse(String scourse) {
this.scourse = scourse;
}
}
----------------------------------------------------

View All Comments | View Tutorial
Related Tutorial and Articles
Struts Examples

Struts 2, JPA and Hibernate Training
Struts 2, JPA and Hibernate Training      ... master Struts 2, JPA and Hibernate. This training is designed for beginners... development. So, don't wait, start Struts 2, JPA and Hibernate Training! About 

IDE Questions

JPA
JPA  HOW CAN I WRITE A SIMPLE PROGRAM IN NETBEANS CONSOLE ON JPA ON CRUD APPLICATION? HOW CAN I START KINDLY HELP ME 

IDE Questions

JPA
JPA  Sir, I have tried making the jpa application which you have given on this site . But then also I m facing problem in that like : If i make then also it is giving error. If I try to run the application provided by you 

IDE Questions

JPA
JPA   I HAVE MADE A PROJECT IN I HAVE MADE ONE - ONE RELATION MY CODE IS ALSO RIGHT FROM MY POINT OF VIEW. AND WHEN I RUN IT IS GIVING ME THE MESSAGE AS BELOW::::::: run: [EL Info]: 2012-02-27 09:42:36.466--ServerSession 

Training

JPA Training
JPA Training     The Java... and the Java collections framework.  JPA Training Objectives  ... programming. JPA Training Course Prerequisites Before learning this course, we 

Struts-Tutorials

Struts 2, JPA and Hibernate Training
Struts 2, JPA and Hibernate Training       The Struts 2, JPA and Hibernate Training for developing enterprise applications...: 5.0 day(s) Online material (Lectures in case of corporate training 

Struts-Tutorials

Struts 2, JPA and Hibernate Training
 

Hibernate Questions

Hibernate & JPA
Hibernate & JPA  What is difference between JPA and Hibernate ? Both of them look similar then what is the exact difference between them 

JPA

JPA Tutorial
JPA Tutorial In this section we will discuss about the Java Persistence API. This section will describe you all the aspects of JPA such as what is JPA, architecture of JPA, features of JPA, JPA entities, entity inheritance JPA, how 

Hibernate-Tutorials

Hibernate JPA
In this section, you will learn about JPA with Hibernate 

JPA

JPA Architecture
JPA Architecture       JPA Architecture: In this section we will discuss the architecture of JPA specification. Java Persistence API or JPA for short is a lightweight, POJO 

Training

Integrated Struts 2 Hibernate and JPA Training
Integrated Struts 2 Hibernate and JPA Training     This training is delivered through online video conference through out the world. Our experts will be providing the training from the coming 

Hibernate Questions

Need Jar in the JPA examples
Need Jar in the JPA examples  JPA - tutorial is good, very easy.... and how Hibernates are used in the JPA example? Thnaks Abhijit Das   .../jpa/ http://www.roseindia.net/jpa/jpacrud/index.shtml http://www.roseindia.net 

JPA

JPA Introduction
JPA Introduction       This section introduces you with the Java Persistence API (JPA). We will learn the benefits of JPA specification. We will also list down the ORM 

EJB Questions

JPA delete query - EJB
JPA delete query  Hi, I have an entity InvoiceItems.java. I want to delete all the records from the table. What will be the JPA query to delete all the data. Please let's know. Thanks   Hi, JPA is very 

JPA

JPA Examples In Eclipse
JPA Examples In Eclipse       In the JPA Examples section we will provide you almost all the examples of JPA framework. This complete JPA tutorials will illustrate you 

JPA

JPA Features
JPA Features       In this section we will discuss about the features of JPA (Java Persistence API). This section will give you an idea about the capabilities of JPA based 

Java Technology Tutorials

JPA Native Queries, JPA Native Queries Tutorials
JPA Native Queries       In this section, you will know about the jpa native queries and how to use native query in your JPA application.  JPA Native Queries: JPA native 

JPA

JPA Relationship
JPA Relationship          In this section, you will know about the jpa relationship. JPA supports the relationship between entities. There are following types 

JPA

JPA Crud
JPA Crud       In this section we will show you how to develop simple CRUD application using JPA... the application. This simple JPA CRUD application can be the base for your future 

JPA

JPA Ordering
JPA Ordering       In this section, you will learn about the JPA Ordering and how to develop JPA application using ordering. JPQL queries can contains ORDER BY clause 

JPA

JPA Grouping
JPA Grouping       In this section, you will learn about the JPA Grouping and how to use it in your JPA application. The GROUP BY clause is used with SELECT statement to retrieve 

JPA

JPA executeUpdate
JPA executeUpdate      ... in your  JPA application. To use executeUpdate() method in your jpa application for executing a jpa UPDATE/DELETE query. This method returns the number of objects 

EJB Questions

Could not open JPA EntityManager for transaction
Could not open JPA EntityManager for transaction  Hi, I am getting following error: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException 

JPA

JPA Examples
JPA Examples In this section we will discuss about the examples of JPA. This section will describe you the various examples that will help you create JPA applications. In this page you will find various examples like methods of JPA 

JPA

JPA getSingleResult
JPA getSingleResult      ... is your JPA application.  getSingleResult(): This is the method...=Persistence.createEntityManagerFactory("jpa"); EntityManager em=emf.createEntityManager 

Hibernate-Tutorials

Spring Jpa Hibernate
In this section, you will learn about integrating Spring 3 MVC with Hibernate Jpa using a example 

JPA

JPA-QL Queries
JPA-QL Queries       In this section, we will use the simple JPA-QL query in our JPA application. Here JPA-QL query used with createQuery() method of EntityManager 

JPA

JPA Named Parameter
JPA Named Parameter       In this section, you will learn how to use JPA Named Parameter in your jpa application. In JPA named parameter is used where you assign names 

Java Technology Tutorials

JPA getResultList Example
JPA getResultList Example   ... the getResultList() method in your JPA application.  getResultList(): This method...=Persistence.createEntityManagerFactory("jpa"); EntityManager em=emf.createEntityManager(); try 

JSP-Tutorials

JPA Named Queries
JPA Named Queries       In this section, you will know about the JPA Named Queries and how to use in JPA application. @NamedQueries: If you need to use more than one 

JPA

JPA Positional Parameter
JPA Positional Parameter       In this section, you will learn about the JPA Positional Parameter and how to use in your JPA application. JPA Queries are convenient to pass 

JPA

JPA Named Parameter List
JPA Named Parameter List       In this section, you will learn how to develop a JPA application using JPA Named Parameter List. This is similar as named parameter 

EJB Questions

Join problem with JPA Criteria Builder
Join problem with JPA Criteria Builder  I need to make this Query in criteria Builder. At this momento IÃ?´m making it like this: Root<Setting> settingRoot = cr.from(Setting.class); Join<Setting, SettingValue> 

JPA

JPA update data Example
JPA update data Example       In this section, you know how to update the database data through the jpa... JPA merge() method Follow the following steps 

JPA

JPA Examples in NetBeans
JPA Examples in NetBeans     ... to run JPA applications. NetBeans IDE provides industry standard features... the business. You can download the JPA example code from the link provides 

JPA

JPA Count Function
JPA Count Function       In this section, you will learn about the count function of JPA aggregate function. JPA Count function counts all records to database table. JPA Count 

JPA

JPA update data
JPA update data       In this section, you know how to update the database data through the jpa. You follow the following steps for updating the data. Create " 

JPA

JPA update data
JPA update data       In this section, you know how to update the database data through the jpa. You follow the following steps for updating the data. Create "JPAUpdate" 

Hibernate Questions

JPA Query with where clause and group by function
JPA Query with where clause and group by function  Any thing wrong in my JPA Query. TypedQuery<RaBdrRating> uQuery = (TypedQuery<RaBdrRating>) entityManager.createQuery("SELECT activePackage,SUM(duration),SUM 

JPA

Developing JPA CURD Application with Eclipse
Developing JPA CURD Application with Eclipse... will learn how to develop JPA CRUD application in eclipse IDE. Eclipse is one... will learn steps to setup a jpa application in eclipse IDEs. Eclipse 

JPA

JPA setParameter (Named Parameter)
JPA setParameter (Named Parameter)       In this section, you will learn the JPA Query API's method setParameter as a named parameter. JPA Query API's supports two 

Java Technology Tutorials

JPA Max Function
JPA Max Function       In this section, you will learn how to develop a jpa max function. JPA max function retrieves data from the database table field which 

Java Technology Tutorials

JPA Sub-Queries
JPA Sub-Queries       In this section, you will see how to use sub-queries in your JPA... components in a single query. JPA Sub-queries:  Query query 

JPA

Developing JPA CURD Application with NetBeans
Developing JPA CURD Application with NetBeans... to develop JPA CRUD application in NetBeans IDEs. First, we will explain the process of setting a jpa application in NetBeans IDEs. Setting up project 

JPA

JPA setMaxResults Example
JPA setMaxResults Example   ... the setMaxResults() method in your JPA application. The setMaxResults function is used... EntityManagerFactory emf=Persistence.createEntityManagerFactory("jpa 

Hibernate Questions

jpa one-to-many persist children with its ID by EntityListeners
jpa one-to-many persist children with its ID by EntityListeners  jpa one-to-many persist children with its ID by EntityListeners 

JPA

JPA delete data
JPA delete data      ... using JPA api. JPA provide remove(Object) to remove the object from... the object and then remove the object using remover(Object) method of JPA api 

Hibernate Questions

jpa one-to-many persist children with its ID
jpa one-to-many persist children with its ID  I have two tables like Organization and region ,both table having one to many relationship.when i persist the organization table it also persist to region . Here i Wont manually 

Framework Questions

What is the difference between EJB 3.0 and JPA - Framework
What is the difference between EJB 3.0 and JPA   What is the difference between EJB 3.0 and JPA. How can they work together. Does EJB 3.0 need...; Hi friend, The Java Persistence API, sometimes referred to as JPA 

JPA

JPA Tutorials
JPA Tutorials          JPA Tutorials and Example: Here we are providing easy to learn JPA tutorials. All the JPA concepts discussed here 

JPA

JPA setFirstResult Example
JPA setFirstResult Example       In this section, you will learn how to use setFirstResult method in your jpa application. The setFirstResult(N) method is used 

Java Technology Tutorials

JPA Named Query
JPA Named Query       In this section, you will read about the JPA Query, its types and how to use the JPA Named Query in your JPA application. JPA Query is powerful 

JPA

JPA Abs Function
JPA Abs Function       In this section, you will learn about the JPA Abs() function. This method returns absolute value of the given field. JPA Abs Function 

JPA

JPA Sqrt Function
JPA Sqrt Function       In this section, you will learn about the JPA sqrt() function. This method returns the square root of the given argument. JPA sqrtFunction 

Training

IT Training and Placement
IT Training and Placement We provide training in latest software technologies to the B.Tech and MCA fresher's. Our IT Training and Placement division... technologies. Our IT Training course is well structured and provides enough 

JPA

JPA Upper Function
JPA Upper Function       In this section, you will learn about the JPA Upper() function. This function returns upper-case of the specified string arguments. JPA Upper 

JPA

JPA update data
JPA update data       In this section, you know how to update the database data through the jpa. You follow the following steps for updating the data. 1--Create 

JPA

JPA Mod Function
JPA Mod Function       In this section, you will learn about the jpa mod function. This function returns the modulo of number and divisor.  For JPA mod 

JPA

JPA Lower() Function
JPA Lower() Function       In this section, you will learn about the jpa lower function. The Lower() function returns the lower-case of given string.  JPA Lower 

JPA

JPA Length Function
JPA Length Function       In this section, you will learn about the JPA length... argument.. JPA Length Function: Query query=em.createQuery("SELECT 

Hibernate Questions

Im getting this error while running JPA project
Im getting this error while running JPA project  Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: examplePersistenceUnit] Unable to configure EntityManagerFactory 

Hibernate Questions

JPA CriteriaBuilder - How to use ?IN? comparison operator
JPA CriteriaBuilder - How to use ?IN? comparison operator  Can you please help me how to convert the following codes to using "in" operator... "in". ***I also tried to search using JPA CriteriaBuilder - "in" method but cannot find 

Java Technology Tutorials

MCA Project Training
Project Training in Integrated Struts 2 Hibernate and JPA · MCA Project... MCA Project Training    ... need a professional training. A school or college study is not sufficient 

Hibernate Questions

jpa one-to-many persist children with its ID
jpa one-to-many persist children with its ID  @Entity public class Item { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column private Long id; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY 

Training

Online Training Schedule
Online Training Schedule Here is the schedule of upcoming online Training. These training are delivered online with the help of desktop sharing software... is necessary to attend the training session. Course will start at pre 

JPA

JPA Many-to-one Relationship
JPA Many-to-one Relationship   ... in your JPA Application. Many-to-One: In this relationship many related records... many-to-one relationship: To develop the JPA Many-to-One relation, you need 

Java Technology Tutorials

JPA One-to-Many Relationship
JPA One-to-Many Relationship     ... the one-to-many relationship and how to develop a one-to-many relation in your JPA... relationship: To develop the JPA One-to-Many relation, you need the following 

Java Technology Tutorials

JPA Many-to-Many Relationship
JPA Many-to-Many Relationship     ... JPA Application. Many-to-many: In this relationship each record in Table-A may... relationship: To develop the JPA Many-to-Many relation, you need 

JPA

JPA Locate Function
JPA Locate Function       In this section, you will learn about the JPA locate...;. JPA locate Function: Query query= em.createQuery("SELECT 

Struts-Tutorials

CRUD application in JPA
CRUD application in JPA      ... a CRUD application in JPA (Java Persistence APIs).  Table name... the CRUD application in JPA : Step 1: The hibernate.cfg.xml 

JPA

Creating and running the JPA CRUD application
Creating and running the JPA CRUD application       In this section we will develop the project articles for JPA application using NetBeans IDE. Follow 

JPA

JPA Min Function
JPA Min Function       In this section, you will learn about the min function of JPA... result. JPA Min Function:  Query query=em.createQuery( " 

JPA

JPA read data from database example
JPA read data from database example       In this section, you will learn how to retrieve data from database using JPA. Create a "JPARead.java" file 

Java Server Faces Questions

Hibernate JSF JPA Integration Error - Java Server Faces Questions
Hibernate JSF JPA Integration Error  Hibernate JSF JPA Error I am trying to configure hibernate, JSF and JPA on Jboss server. I am getting following error. 11:55:53,625 FATA  Hi,After long struggle I finally got 

JPA

Creating and running the JPA CRUD application
Creating and running the JPA CRUD application   ... different project artifacts for JPA CRUD demo example code. After completing... the CRUD demo application. Following the following steps to create the JPA 

Training

Free J2EE Online Training
Free J2EE Online Training The Enterprise Edition of Java popularly known... professionals free online J2EE training there are various websites but the quality of training they are giving is always under suspicion. The program commonly used 

JPA

JPA read data from database example
JPA read data from database example       In this section, you will learn how to retrieve data from database using JPA. Create a "JPARead.java" file and follows 

Training

J2EE Online Training
J2EE Online Training Due to increasing significance of Java Enterprise Edition or Java 2 EE, the need for J2EE online training has increased manifold... to the occasion, various institutes are offering online J2EE training to those who 

Training

Hibernate Training
; Hibernate Training Course Objectives.... Hibernate Training Course Outline  .../relational mapping with Hibernate Java Persistence API (JPA 

JPA

Add Jar in JPA project
Add Jar in JPA project       In this section, you add all required jar files. Right click on "Library". The following screen is appear on the screen 

Free Magazine

Maven2 with JPA Example
Maven2 with JPA Example           Getting Started with Maven2 Download Maven2 from maven.apache.org, unzip the archive into your local directory. Here we 

JPA

JPA Sum Function
JPA Sum Function      ... in your jpa application. JPA Sum Function: Query query=em.createQuery("... EntityManagerFactory emf=Persistence.createEntityManagerFactory("jpa 

Programming Tutorials

Creating files in jpa project
Creating files in jpa project       After creating "JPACRUDApplication" project, you need to follow the following steps: Right click on "Source 

JPA

JPA Trim() Function
JPA Trim() Function     .... This function will trimmed the space character from your given string. JPA... characters from the given string as sname. For JPA Trim application, you need 

JPA

JPA Substring() Function
JPA Substring() Function   ..., second is starting index and third is length of string . JPA Substring...'"); For JPA substring application, you need the following artifacts 

Java Technology Tutorials

JPA setParameter (Numbered Parameter)
JPA setParameter (Numbered Parameter)  .... Positional parameter number and its value. It also returns an instance of jpa...=Persistence.createEntityManagerFactory("jpa"); EntityManager em=emf.createEntityManager(); try 

Hibernate-Tutorials

net.roseindia.controller
This package contains controller class of Spring and Hibernate Jpa integration application 

JPA

JPA delete data
JPA delete data       In this section, you will learn how to delete data from database. You follow the  following steps: Create a "JPADelete" class file 

JPA

JPA delete data
JPA delete data       In this section, you will learn how to delete data from database. You follow the  following steps: Create a "JPADelete" class file 

JSP-Tutorials

JPA Concat Function
JPA Concat Function       In this section, you will learn about the JPQL (Java... of student table. For JPA Concat application, you need the following artifacts 

Java Technology Tutorials

JPA Avg Function
JPA Avg Function       In this section, you will learn the avg of aggregate function. This method calculate an average of  given data. JPA Avg() function 

Training

IT Training in India
; JPA Training  The Java Persistence API Training Course... Hibernate and JPA Training This training is delivered through online video conference... IT Training in India Welcome to Rose India 

JPA

Select your project and right click on the it
Creating files in JPA project       After creating "JPACRUDApplication" project, you need to follow the following steps: Select " 

JPA

JPA One-to-One Relationship
JPA One-to-One Relationship          In this section, you...:   Download JPA Annotation Relationship Application 

Free Magazine

Working with Entity bean using JPA
Working with Entity bean using JPA           Working with Entity bean using JPA An entity defines a table (consisting of rows and columns) in a relational 

JSP Servlet Questions

JSP COMILATION ERRO - JSP-Servlet
 

Training

Java Courses
and classroom training. Our Java Courses content is well designed and supported with many... are delivered as online, onsite, classroom training sessions. You can take these courses... training sessions. Group training in Java is cheaper then the individual one 

Design concepts & design patterns Questions

Training
Training  Hi, What is training and how I can get the benefits of training? Is online training effective? Thanks   HI, Training is the processing of giving knowledge to a person or group. These days online training 

Java Beginners

IT Training
IT Training  Hi, Why IT Training is important in gaining latest technology knowledge? Thanks   Hi, IT training helps the developers to learn new technologies very fast. If you are learning new technologies yourself 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.