[ https://issues.apache.org/jira/browse/OPENJPA-2839?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
CHAN Shih-Ping updated OPENJPA-2839: ------------------------------------ Description: With Entity table named USERS, OpenJPA+H2 is incorrectly detecting that table exists because it finds INFORMATION_SCHEMA.USERS. Using H2 as JDBC driver and metadata-only DDL schema generation: {code:java} <property name="javax.persistence.schema-generation.database.action" value="drop-and-create" /> <property name="javax.persistence.sql-load-script-source" value="initial-data.sql" />{code} The connection string is {{jdbc:h2:mem:testdb}}. The Entity table is named "Users" but OpenJPA misdetects that the table exists (it searches in the INFORMATION_SCHEMA as well, it seems), and so does not send "CREATE TABLE..". Instead it sends "ALTER TABLE...". In H2 this targets the PUBLIC schema and so will fail as the "Users" table does not exist in the PUBLIC schema. In contrast, hibernate correctly detects that the table does not exist, and sends "CREATE TABLE...". was: Using H2 as JDBC driver and metadata-only DDL schema generation: {code:java} <property name="javax.persistence.schema-generation.database.action" value="drop-and-create" /> <property name="javax.persistence.sql-load-script-source" value="initial-data.sql" />{code} The connection string is {{jdbc:h2:mem:testdb}}. The Entity table is named "Users" but OpenJPA misdetects that the table exists (it searches in the INFORMATION_SCHEMA as well, it seems), and so does not send "CREATE TABLE..". Instead it sends "ALTER TABLE...". In H2 this targets the PUBLIC schema and so will fail as the "Users" table does not exist in the PUBLIC schema. In contrast, hibernate detects that the table does not exist, and sends "CREATE TABLE...". > OpenJPA+H2 is finding USERS table from INFORMATION_SCHEMA > --------------------------------------------------------- > > Key: OPENJPA-2839 > URL: https://issues.apache.org/jira/browse/OPENJPA-2839 > Project: OpenJPA > Issue Type: Bug > Components: jpa > Affects Versions: 3.1.0 > Environment: Java 11, OpenJPA 3.1.0 (from TomEE), H2 1.4.200 > Reporter: CHAN Shih-Ping > Priority: Major > > With Entity table named USERS, OpenJPA+H2 is incorrectly detecting that table > exists because it finds INFORMATION_SCHEMA.USERS. > > Using H2 as JDBC driver and metadata-only DDL schema generation: > {code:java} > <property name="javax.persistence.schema-generation.database.action" > value="drop-and-create" /> > <property name="javax.persistence.sql-load-script-source" > value="initial-data.sql" />{code} > The connection string is {{jdbc:h2:mem:testdb}}. > > The Entity table is named "Users" but OpenJPA misdetects that the table > exists (it searches in the INFORMATION_SCHEMA as well, it seems), and so does > not send "CREATE TABLE..". > Instead it sends "ALTER TABLE...". In H2 this targets the PUBLIC schema and > so will fail as the "Users" table does not exist in the PUBLIC schema. > In contrast, hibernate correctly detects that the table does not exist, and > sends "CREATE TABLE...". -- This message was sent by Atlassian Jira (v8.3.4#803005)