When learning hibernate, the database uses PostgreSQL, the first lesson is thrown wrong, user entity mapping is not alive or alive cannot export the table. Always prompt this sentence:
Error:syntax ERROR at or near "User".
Later found that if the table name is set to t_user such a line, not PostgreSQL can not be capitalized? Try T_user again, no error, to the database to see, eh? or t_user!? uppercase automatically becomes lowercase. PostgreSQL does not recognize the case? Creating a user table with the Pgadmin graphical interface is no problem at all. After experimenting with the fields in the table, I found that it was also the problem, always prompting Error:syntax error at or near "..."
To look at Pgadmin's SQL window suddenly found ( many times careful observation is really important AH ), there are uppercase places are added double quotation marks
Oh, suddenly enlightened, not do not recognize the case, the mystery of the original in double quotation marks.
First use the SQL statement to try to establish a name is a capital letter table, remember the table name plus double quotation marks, run error-free, success!
Hibernate example has two solutions, one, is the table name in lowercase, the other is uppercase double quotation marks, of course, this time you will ask, both double quotation marks do not ah, with the escape symbol chant.
In the JPA example:
Summary:
- PostgreSQL is case-sensitive for table names and field names. The graphical interface can be created normally. Use the SQL statement with double quotes, if the JDBC query, etc., remember to use the escape symbol.
- PostgreSQL is not sensitive to capitalization in SQL statements
Select ID from t_user and select ID from T_user
Will query the ID field from the T_user table. If you want to query the fields in uppercase letters, double quotation marks are also added: select "ID" from T_user
Table name, field name capitalization problem in "Goto" PostgreSQL