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

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top