troubleshooting Question

"ID": invalid identifier in hibernate application

Avatar of senecaglobal
senecaglobalFlag for India asked on
JavaJava EE
8 Comments1 Solution2696 ViewsLast Modified:
I developed a standalone  hibernate application using hibernate3.2 version. when i run the application i'm getting the following error.i attached all the source files.

 java.sql.BatchUpdateException: ORA-00904: "ID": invalid identifier
Any solution?

package com.surya.hibernate;

public class MyContact {
	  private String firstName;
	  private String lastName;
	  private String email;
	  private long id;
	public String getFirstName() {
		return firstName;
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	public String getLastName() {
		return lastName;
	public void setLastName(String lastName) {
		this.lastName = lastName;
	public String getEmail() {
		return email;
	public void setEmail(String email) { = email;
	public long getId() {
		return id;
	public void setId(long id) { = id;


FirstExample .java

package com.surya.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class FirstExample {
  public static void main(String[] args) {
    Session session = null;

      // This step will read hibernate.cfg.xml and prepare hibernate for use
      SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
       session =sessionFactory.openSession();
        //Create new instance of Contact and set values in it by reading them from form object
         System.out.println("Inserting Record");
        MyContact contact = new MyContact();
    }catch(Exception e){
      // Actual contact insertion will happen at this step


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<!-- Generated Oct 5, 2010 10:14:49 AM by Hibernate Tools 3.3.0.GA -->
    <class name="com.surya.hibernate.MyContact" table="MYCONTACT">
        <id name="id" type="long">
            <column name="ID" />
            <generator class="assigned" />
        <property name="firstName" type="java.lang.String">
            <column name="FIRSTNAME" />
        <property name="lastName" type="java.lang.String">
            <column name="LASTNAME" />
        <property name="email" type="java.lang.String">
            <column name="EMAIL" />


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
		"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@//localhost:1521/DB1</property>
        <property name="hibernate.connection.username">scott</property>    
		<property name="hibernate.connection.password">tiger</property>     
		<property name="hibernate.connection.pool_size">10</property>    
		<property name="show_sql">true</property>
        <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> 
		<!-- Mapping files -->
		<mapping resource="contact.hbm.xml"/>

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros