I'm using netbeans 6.9 and Hibernate and I'm trying to insert some values in a database (postgres) but I get the following exception:
INFO: Not binding factory to JNDI, no JNDI name configured Exception in thread "main" org.hibernate.MappingException: Unknown entity: SELECTPACK.beanClass at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550) at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:3
and my hbm.xml file is given below
<class name="SELECTPACK.beanClass" table="login">
<id column="id" name="id">
<generator class="increment"/>
</id>
<property name="username" column="username"/>
<property name="password" column="password"/>
</class>
my cfg.xml file is given below
<?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="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://192.168.1.100:54321/postgres</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">dbserver</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="SELECTPACK/select.hbm.xml"/>
</session-factory>
</hibernate-configuration>
my pojo class
package SELECTPACK;
public class beanClass {
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
and hear is my main class
package SELECTPACK;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class selectMainClass {
public static void main(String... args) {
SessionFactory sessionFact = new Configuration().configure().buildSessionFactory();
Session ses = sessionFact.openSession();
Transaction tx = ses.beginTransaction();
beanClass bean = new beanClass();
bean.setPassword("hi....");
bean.setUsername("hi....");
ses.save(bean);
tx.commit();
/*String query = "select * from login";
Query qry = ses.createQuery(query);
ArrayList list = (ArrayList) qry.list();
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}*/
ses.close();
}
}
I don't understand what the problem is.