Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to escape keywords with JPA
PostPosted: Thu Mar 16, 2017 11:54 pm 
Newbie

Joined: Thu Mar 16, 2017 11:46 pm
Posts: 2
im use hibernate and MySQL,when i use 'describe' as column name.my code return:

org.hibernate.exception.SQLGrammarException: could not execute statement

java.sql.SQLSyntaxErrorException: 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 'describe='for test', islocked=0, permission_code='add,edit', role_name='test_rol' at line 1


Top
 Profile  
 
 Post subject: Re: how to avoid some word can lead Exception
PostPosted: Fri Mar 17, 2017 2:15 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1038
You need to escape your column name as follows:

Code:
@Column(name ="\"describe"\")
private String describe;

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: how to avoid some word can lead Exception
PostPosted: Fri Mar 17, 2017 2:23 am 
Newbie

Joined: Thu Mar 16, 2017 11:46 pm
Posts: 2
vlad wrote:
You need to escape your column name as follows:

Code:
@Column(name ="\"describe"\")
private String describe;



thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.