my data base table contains 4 columns
1.docid.2.first.3.middle.4.last
my hibernate config xml is given below
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">
jdbc:postgresql://localhost/newgenlib
</property>
<property name="hibernate.connection.driver_class">
org.postgresql.Driver
</property>
<property name="hibernate.connection.username">
postgres
</property>
<property name="hibernate.connection.password">
girish
</property>
<property name="hibernate.connection.pool_size">
0
</property>
<!--<property name="hibernate.jdbc.batch_size">0</property>-->
<property name="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect
</property>
<property name="hibernate.show_sql">
true
</property>
<property name="connection.autocommit">
false
</property>
<!-- "Import" the mapping resources here -->
<mapping resource="InsertBean.hbm.xml"/>
</session-factory>
</hibernate-configuration>
mapping xml
Insertbean.xml
<?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="InsertBean" table="InsertBean">
<id column="docid" unsaved-value="-1" type="integer">
<generator class="sequence">
<param name="sequence">sequence_id</param>
</generator>
</id>
<property name="First" column="first" type="string"/>
<property name="Middle" column="middle" type="string"/>
<property name="Last" column="last" type="string"/>
</class>
</hibernate-mapping>
my pojo class is given below
public class InsertBean
{
public String First;
public String Middle;
public String Last;
public InsertBean()
{
}
public InsertBean(String First,String Middle,String Last)
{
this.First=First;
this.Middle=Middle;
this.Last=Last;
}
public String getFirst()
{
return this.First;
}
public void setFirst(String First)
{
this.First=First;
}
public String getMiddle()
{
return this.Middle;
}
public void setMiddle(String Middle)
{
this.Middle=Middle;
}
public String getLast()
{
return this.Last;
}
public void setLast(String Last)
{
this.Last= Last;
}
}
MyServlet
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyServlet extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
System.out.println("INSIDE SERVLET");
HibernateInsert hi=new HibernateInsert();
hi.insert();
}
}
HibernateInsert.java
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateInsert
{
public void insert(){
SessionFactory factory =
new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();
session.beginTransaction();
InsertBean m1 = new InsertBean();
m1.setFirst("new");
m1.setMiddle("gen");
m1.setLast("lib");
session.save(m1);
session.getTransaction().commit();
session.close();
}
}
when i execute this web application i am getting this exception please help me
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update