Hibernate version:
hibernate-distribution-3.3.1.GA
Mapping documents
None
Code between sessionFactory.openSession() and session.close():
Code:
package com.gss.DAO;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import com.gss.POJOs.Student;
public class Test{
public static void main(String args[])
{
Session session = null;
try{
SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
session=sessionFactory.openSession();
Student stud = new Student();
stud.setId(1);
stud.setName("Arul");
session.save(stud);
session.flush();
}catch(Exception e){
e.printStackTrace();
}
}
}
Full stack trace of any exception that occurs:Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
at com.gss.DAO.Test.main(Test.java:14)
Name and version of the database you are using:Oracle 10g
The generated SQL (show_sql=true):Don't know.
Debug level Hibernate log excerpt:Don't know.
Hi All,
I basically have a table called STUDENT in the Oracle 10g database with ID as primary key and Name as another column and I am trying to insert into the table values using Annotations so I basically don't have a Mapping file. The DAO Class is already given above. Here's the POJO class and the config files.
Pojo:Code:
package com.gss.POJOs;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "STUDENT")
public class Student implements Serializable {
@Id
@Column(name = "ID")
Integer id;
@Column(name = "NAME")
String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
hibernate.cfg.xml file:Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="connection.url">
jdbc:oracle:thin:@localhost:1521:XE
</property>
<property name="connection.username">
System
</property>
<property name="connection.password">
1234
</property>
<!-- Set AutoCommit to true -->
<property name="connection.autocommit">
true
</property>
<!-- SQL Dialect to use. Dialects are database specific -->
<property name="dialect">
org.hibernate.dialect.OracleDialect
</property>
<!-- Mapping files -->
<mapping class="com.gss.POJOs.Student" />
</session-factory>
</hibernate-configuration>
I actually had the following error when I did not have
sl4j-log4j12-1.5.6 added to my build path:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See
http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
at com.gss.DAO.Test.main(Test.java:14)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 3 more
And when I added it, All of this disappeared and the error first described (Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory)is appearing now. Can someone tell me what to do?/
Thanks.