How to get SQL query string when using Hibernate?

Z

ZelluX

Hi, all

I have a problem when saving my bean to the MySQL server using
Hibernate.
Here's the code snippet when saving the bean

Session session = HibernateSessionFactory.getSession();
Transaction tx = session.beginTransaction();
session.save(user);
tx.commit();

But it throws an exception, which contains
Caused by: java.sql.BatchUpdateException: 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 'name, gender, birthday,' at
line 1

Then how to find out that sql query string generated by hibernate?

Or any other way to debug it?

Many thanks
 
A

Arne Vajhøj

ZelluX said:
I have a problem when saving my bean to the MySQL server using
Hibernate.
Here's the code snippet when saving the bean

Session session = HibernateSessionFactory.getSession();
Transaction tx = session.beginTransaction();
session.save(user);
tx.commit();

But it throws an exception, which contains
Caused by: java.sql.BatchUpdateException: 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 'name, gender, birthday,' at
line 1

Then how to find out that sql query string generated by hibernate?

<property name="show_sql">true</property>

in Hibernate config.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top