Helloo hibernators!
Im trying to use anottations to avoid doing the xml mapping file of the entity.
i have this POJO:
Quote:
import java.io.Serializable;
import javax.*;
import javax.persistence.Entity;
import javax.persistence.*;
@Entity
@Table (name="Employee")
public class Person {
@Id
@GeneratedValue (strategy = GenerationType.AUTO)
long id;
@Column (nullable=false, length=50)
String name;
@Column (nullable=false)
int age;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
this hibernate.cfg.xml
Quote:
<?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">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:jtds:sqlserver://127.0.0.1:1433/base1</property>
<property name="hibernate.connection.username">jorge</property>
<property name="hibernate.connection.password">xxx</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.generate_statistics">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping class="Person"/>
</session-factory>
</hibernate-configuration>
and i am getting the following error!!!!!!!....
Quote:
java.lang.NoSuchMethodError: org.hibernate.util.ReflectHelper.classForName(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Class;
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:752)
at HibernateUtil.<clinit>(HibernateUtil.java:12)
at PersonDAO.insertPerson(PersonDAO.java:13)
at Client.main(Client.java:17)
Exception in thread "main" java.lang.NullPointerException
at PersonDAO.insertPerson(PersonDAO.java:13)
at Client.main(Client.java:17)
I cant find what this error could be in any forum !
Your help would be much appreciated!
Thanks,
Jorge