[ 
https://issues.apache.org/jira/browse/TORQUE-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17904795#comment-17904795
 ] 

Max Philipp Wriedt commented on TORQUE-369:
-------------------------------------------

There is a restriction with SQL to not being able to resolve foreign keys in 
another sql file. So ExternalSchemaTransformer is the wrong Transformer to 
apply this fix.
LoadIncludeSchemaTransformer on the other hand includes a file for generation 
into the same sql-file, so this is the location where a fix is necessary.

Closing this in favor for another issue.

> LoadExternalSchemaTransformer recursively includes when cross-referencing
> -------------------------------------------------------------------------
>
>                 Key: TORQUE-369
>                 URL: https://issues.apache.org/jira/browse/TORQUE-369
>             Project: Torque
>          Issue Type: Bug
>          Components: Templates
>    Affects Versions: 5.1, 6.0
>            Reporter: Max Philipp Wriedt
>            Assignee: Max Philipp Wriedt
>            Priority: Major
>
> When referencing an external schema (to use foreign key references in another 
> schema definition) and back referencing to its origin, we get an infinite 
> recursion.
> Affects: 
> org.apache.torque.templates.transformer.LoadExternalSchemaTransformer.transform()
> Example:
> First Schema:
> {code:java}
> <?xml version="1.0" encoding="UTF-8" ?>
> <database>
>     <external-schema filename=secondary-schema.xml" />
>     <table name="test" javaName="Test">
>         <column name="Id" javaName="Id" required="true" type="INTEGER" 
> primaryKey="true"/>
>         <column name="Name" javaName="Name" required="true" type="VARCHAR" 
> size="5"/>
>         <column name="foreign-key" javaName="ForeignKey" required="true" 
> type="INTEGER" size="2"/>
>         <!-- define foreign key to secondary scheme!-->
>     </table>
> </database>{code}
> Second Schema: 
> {code:java}
> <?xml version="1.0" encoding="UTF-8" ?>
> <database
>     xmlns="http://db.apache.org/torque/5.0/templates/database";
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>     xsi:schemaLocation="http://db.apache.org/torque/5.0/templates/database
>     
> https://db.apache.org/torque/torque-5.0/documentation/orm-reference/database-5-0-strict.xsd";
>  name="test" defaultIdMethod="native" defaultJavaType="object">
>     <external-schema filename=first-schema.xml" />
>     <table name="foreign-key" javaName="Test">
>         <column name="Id" javaName="Id" required="true" type="INTEGER" 
> primaryKey="true"/>
>         <column name="Name" javaName="Name" required="true" type="VARCHAR" 
> size="5"/>
>     </table>
>     <table name="test2" javaName="Test2">
>         <column name="Id" javaName="Id" required="true" type="INTEGER" 
> primaryKey="true"/>
>         <column name="Name" javaName="Name" required="true" type="VARCHAR" 
> size="5"/>
>         <column name="foreign-key" javaName="ForeignKey" required="true" 
> type="INTEGER" size="2"/>
>         <!-- define foreign key to first scheme!-->
>     </table>
> </database>{code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org

Reply via email to