Eaton Eaton - 2 years ago 109
SQL Question

Error on SQL generated by Hibernate

Does anybody know why the SQL query generated by Hibernate is wrong? I tried to create a table from entity automatically using property
in the entity to set the default value. When I run the program I got this error:

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 '`varchar(100) default '-'`,
`last_name` varchar(100), primary key (`id'

Here is the generated SQL query:

create table `user` (
`id` bigint not null auto_increment,
`first_name` `varchar(100) default '-'`,
`last_name` varchar(64),
primary key (`system_id`)

Of course that was wrong, Hibernate add a tick character (`) for translating
in the entity, here is the entity class:

@Table(name = UserEntity.TABLE_NAME)
public class UserEntity implements Serializable {

public static final String TABLE_NAME = "user";

@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;

@Column(name = "first_name", columnDefinition="varchar(100) default '-'")
private String firstName;

@Column(name = "last_name", length = 100)
private String lastName;

public Long getId() {
return id;

public void setId(Long id) { = 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;


Depedencies in maven:




Please let me know if somebody get the same problem and get the solution. Thank you for your help.

Answer Source

The link on the comment, helped me. The problem is in my hibernate configuration, removing this line fix it.

<property name="hibernate.globally_quoted_identifiers">true</property>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download