[ https://issues.apache.org/jira/browse/TORQUE-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17905077#comment-17905077 ]
Georg Kallidis commented on TORQUE-369: --------------------------------------- This is an extraordinary use-case IMO. Generally you just have a hierarchy of dependencies, no back references in schema dependencies? That is you proceed from a single main (parent) schema, and then descend to child schemata - without back-reference. Technically I would further expect a foreign key reference in a table defined like this: {code:xml} <column default="0" name="other-id" required="true" type="INTEGER" javaType="object"/> <foreign-key foreignTable="other-table"> <reference foreign="id" local="other-id"/> </foreign-key> {code} This requires (ignoring the foreign key check disable statement) that the "other-table" is already known .. which is an issue either of where to place the external schema import or to postpone foreign key checks after all tables are imported and then check them.. Nevertheless to avoid (technically) the recursion this might be done by checking the external schema reference name (in a referenced external schema) to be identical to the schema name from where it is called. The result would be to ignore it. Of course this is almost equivalent to say that it is an error to allow back-references and of course then it should be accompanied with a warning, that the import is ignored. But may be I do not get to the point .. :) > 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