[ 
https://issues.apache.org/jira/browse/OPENJPA-592?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595629#action_12595629
 ] 

Abe White commented on OPENJPA-592:
-----------------------------------

1: The patch proposes to use the table_cat information in place of the schema.  
What does mysql return in the table_cat?  In the example above, for example, 
would the table_cat be "jpa", or something else entirely?  Will treating the 
catalog as the schema mess up calls to methods like 
DatabaseMetaData.getBestRowIdentifier(...), which takes both the catalog and 
schema as arguments?

2.  The table schema information returned from database metadata is not only 
used in the newColumn method, but also in newPrimaryKey, newForeignKey, 
newIndex, and possibly newSequence.  If we override newColumn in 
MySQLDictionary to use table_cat instead, don't we need to make corresponding 
changes to all these methods?  

> In MySQL explicitly specifying openjpa.jdbc.Schema with default schema gives 
> an error on first time EM access if mapping is already done
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-592
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-592
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>            Reporter: Jason Zheng
>         Attachments: patch-592.txt
>
>
> Suppose we have an entity "Employee" and we have the following properties 
> specified in persistence.xml:
> <property name='openjpa.jdbc.SynchronizeMappings'  
> value='buildSchema(ForeignKeys=true)' />
> <property name='openjpa.jdbc.Schema' value='jpa' />
> OpenJPA  should create table "jpa:employee" if it does not exist in the 
> database, and do nothing if the table already exists.
> But in MySQL, it tries to create the table when the table already exists in 
> database, and we will get the following exception because of this:
> <openjpa-1.1.0-SNAPSHOT-r422266:647033 nonfatal general error> 
> org.apache.openjpa.persistence.PersistenceException: Table 'employee' already 
> exists {stmnt 7294825 CREATE TABLE jpa.employee (id BIGINT NOT NULL, PRIMARY 
> KEY (id)) TYPE = innodb} [code=1050, state=42S01]
> at  org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:553)
> at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:453)
> at 
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
> ...
> This is because MySQL doesn't have concept of schema, and the column metadata 
> from MySQL doesn't contain schema information. Hence OpenJPA fails to find 
> the table although the table exists in database.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to