[jira] [Updated] (OPENJPA-2837) HerdDBDictionary does not work with 'native' SchemaFactory (LazySchemaFactory) - set useSchemaName=false by default

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (OPENJPA-2837) HerdDBDictionary does not work with 'native' SchemaFactory (LazySchemaFactory) - set useSchemaName=false by default

Mark Struberg (Jira)

     [ https://issues.apache.org/jira/browse/OPENJPA-2837?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Struberg updated OPENJPA-2837:
-----------------------------------
    Fix Version/s:     (was: 3.2.0)
                   3.2.1

> HerdDBDictionary does not work with 'native' SchemaFactory (LazySchemaFactory) - set useSchemaName=false by default
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2837
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2837
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 3.1.2
>            Reporter: Enrico Olivelli
>            Priority: Critical
>             Fix For: 3.2.1
>
>
> If you want to enable physical Foreign Keys you have to configure SchemaFactory with 'native'.
> In this case the LazySchemaFactory does not handle correctly delimiters and everything breaks, even the creation of OPENJPA_SEQUENCE table.
>  
> The problem is that the query generated for loading the sequence value is:
> {code:java}
> SELECT `SEQUENCE_VALUE` FROM "herd"."`OPENJPA_SEQUENCE_TABLE`" WHERE `ID` = ? FOR UPDATE [params=?]{code}
>  
> It is adding default delimiters to the schema name and the tablename.
> the problem is in TableJDBCSeq.java, using LazySchemaFactory the primary table name is augmented with the schema name ("herd" in this case) and this triggers the 4th case in "resolveTableIdentifier"
>  
>  
> {code:java}
> public DBIdentifier resolveTableIdentifier(ClassMapping mapping, Table table) {
>  DBIdentifier sName = mapping.getTable().getSchemaIdentifier();
>  DBIdentifier tableName = DBIdentifier.NULL;
> //OPENJPA-2650: Don't use a schema name if the user has requested,
>  //via useSchemaName, to not use one.
>  if (!_conf.getDBDictionaryInstance().useSchemaName){
>  tableName = table.getIdentifier();
>  } else if (DBIdentifier.isNull(sName)) {
>  tableName = table.getFullIdentifier();
>  } else if (!DBIdentifier.isNull(table.getSchemaIdentifier())) {
>  tableName = table.getFullIdentifier();
>  } else {
>  tableName = QualifiedDBIdentifier.newPath(sName, table.getIdentifier());
>  }
>  return tableName;
>  }
> {code}
>  
>  
> This tracks down to QualifiedDBIdentifier.newPath(sName, table.getIdentifier()); that basically does not work when you have compound identifiers and delimiters.
> When you are using DynamicSchemaFactory the problem does not arise because we fall into case 2h (QualifiedDBIdentifier.newPath(sName, table.getIdentifier()) ) and we are not passing by QualifiedDBIdentifier.newPath.
>  
> The problem is NOT only in QualifiedDBIdentifier.newPath. but it becomes a problem when you perform SQLBuffer#append, that in turn calls DBDictionary#fromDBName, that tries to add dict specific delimiters (in this case with HerdDBDirection the backtick)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)