Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

When you have a column of the bit data type what Class would be used to represent that in a Java POJO mapping that table to an object which is using javax.persistence annotations?

I tried Boolean, which didn't work and produced the following errors:

org.hibernate.exception.SQLGrammarException: could not insert: [com.DomainClassName]
java.sql.SQLException: Incorrect syntax near '-'.

EDIT: a Java boolean does map to the bit data type in SQL Server. I had a column name with a dash in it that I had to change.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Incorrect syntax near '-'.

This tells me that you've named a database, table or column with a dash in it, not that POJO is having an issue mapping your columns.

As an example, if you've named your entity bar-none and POJO issues the following CREATE TABLE statement:


Or this one:


You will get this error:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.

And in fact even if you declare a data type that does not exist in SQL Server, such as Boolean, Frank or WhatTheHeckDataTypeIsThis, the parser will still barf with the above error due to the hyphen, before it even bothers validating the data type(s).

So, please check your table name and column names and be sure that your names don't use dashes, spaces or other special characters, that they aren't reserved words, and that each name you provide obeys the well-documented rules for identifiers. While you can get around this error if you can coerce POJO to properly delimit bad names with [square brackets], this is not a best practice.

share|improve this answer

I had a similar problem. The following mapping in Java solved the problem:

@Column(name = "columnName", columnDefinition="BIT")
private Boolean columnVariable;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.