Hi,
below is my FirstExample.java file and Contact.hbm.xml file
when run FirstExample.java it is giving error as null, and not deleting the record
FirstExample.java file
import java.sql.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.Query;
import utils.Insurence;
public class FirstExample {
public static void main(
String[] args) {
Session session = null;
try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
String hql = "delete from Book CONTACT1 where id = 2";
Query query = (Query) session.createQuery(hql);
int row = query.executeUpate();
if (row == 0){
System.out.println("Doesn't deleted any row!");
}
else
{
System.out.println("DeletedRow: " + row);
}
}catch(Exception e){
System.out.println("error=="+e.getMessage());
}finally{
session.flush();
session.close();
}
}
}
Contact.hbm.xml file
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="utils.Book" table="CONTACT1">
<id name="lngBookId" type="long" column="ID">
<generator class="increment"/>
</id>
<property name="strBookName">
<column name="Bookname"/>
</property>
</class>
</hibernate-mapping>
output
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
error==null
please any help is helpfull , i dont know why it is coming