If I use annotation @Table("Book_Author")
then I get
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "Book_Author" not found (candidates are: "BOOK_AUTHOR") ...
@Table("Book_Author")
public class BookAuthor {
private Integer author;
public BookAuthor(Integer authorId){
this.author =authorId;
}
}
schema.sql
:
create table Book_Author(
author int not null ,
book int not null ,
primary key (author,book)
);
Without @Table
everything works fine. Please tell me why?
The table name is unquated. It means that the table name is case insensitive in the database and it is converted to uppercase when you use create table
SQL statement. But @Table
annotation is using a table name in a case sensitive manner.
You should read more about quoted and unquated table names Make H2 treat quoted name and unquoted name as the same.
In that H2 behaves in the same way as Oracle. This is a bit different on how other databases like MySQL and PostgreSQL deal with identifier names. H2 has a compatibility feature: If you append
;DATABASE_TO_UPPER=FALSE
to the database URL, unquotes identifiers are not converted to uppercase, that means they are case sensitive as well. But you need append this when creating the database, and each time you use it (if you append the setting for existing databases, the identifiers of existing objects are already converted to uppercase).