Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8199507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:10:54+00:00 2026-06-07T06:10:54+00:00

I am new in Spring and Hibernate. I am trying to insert and retrieve

  • 0

I am new in Spring and Hibernate. I am trying to insert and retrieve all data from database. I have inserted data in mySql db and now i am trying to retrieve all data from database but i am getting some exception. What i can do to fix the problem.

Jul 04, 2012 10:46:58 AM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1064, SQLState: 42000
Jul 04, 2012 10:46:58 AM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: You have an error in your SQL syntax; check the manual that corresponds to     your MySQL server version for the right syntax to use near ') as emp1_0_, employee0_.address as address0_, employee0_.emp_email as emp3_0_, ' at line 1
Hibernate: select employee0_.emp_id) as emp1_0_, employee0_.address as address0_, employee0_.emp_email as emp3_0_, employee0_.manager_id as manager4_0_, employee0_.emp_name as emp5_0_ from employee employee0_
org.hibernate.exception.SQLGrammarException: could not execute query

Hibernate code is

public void getAll() {

    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction transaction = null;
    try {
        transaction = (Transaction) session.beginTransaction();
        List employees = session.createQuery("from Employee").list();
        for (Iterator iterator = employees.iterator(); iterator.hasNext();) {
            Employee employee = (Employee) iterator.next();
            System.out.println(employee.getName());
        }
        transaction.commit();
    } catch (HibernateException e) {
        transaction.rollback();
    } finally {
        session.close();
    }
}

Employee.java

@Entity
@Table(name="employee")
public class Employee {

private int id;
private String name;
private String email;
private String address;
private int managerId;


@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="emp_id)")
public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

@Column(name="emp_name")
public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

@Column(name="emp_email")
public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

@Column(name="address")
public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

@Column(name="manager_id")
public int getManagerId() {
    return managerId;
}

public void setManagerId(int managerId) {
    this.managerId = managerId;
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:10:57+00:00Added an answer on June 7, 2026 at 6:10 am

    this

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="emp_id)")
    public int getId() {
        return id;
    }
    
    should be - 
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="emp_id")
    public int getId() {
        return id;
    }
    

    Remove ) from the end of name="emp_id)"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to insert the values from textfields in the database using hibernate
I have a Spring/JPA/Hibernate application and am trying to get it to pass my
hope everybody is cool.I've been trying to do something with spring-hibernate but it's still
i am new to spring/hibernate and was trying out my first app. I got
I'm trying to use hibernate with spring 3 mvc but at the moment I
I'm trying to create a simple crud form to insert data into a database
I am new to spring and trying to get hibernate work with spring.I tried
I'm kind of new in Spring and hibernate so I'm trying to implement some
I am trying to insert a record into the database i am using Spring
I'm trying to setup Spring using Hibernate and JPA, but when trying to persist

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.