title: How to solve Infinite recursion issue while getting Relationship in Apache meta model?
body: <p>I am trying to get the information of a schema from a big SQL server database using Apache Metamodel but I am getting <code>StackOverflowError</code> exception. Please find the stack trace below:</p>
  <pre><code>Infinite recursion (StackOverflowError) (through reference chain: java.util.Collections$UnmodifiableRandomAccessList[0]-&gt;org.apache.metamodel.schema.MutableRelationship[&quot;primaryColumns&quot;]-&gt;java.util.ArrayList[0]-
  &gt;org.apache.metamodel.jdbc.JdbcColumn[&quot;table&quot;]-&gt;org.apache.metamodel.jdbc.JdbcTable[&quot;relationships&quot;]-&gt;java.util.Collections$UnmodifiableRandomAccessList[0]-
  &gt;org.apache.metamodel.schema.MutableRelationship[&quot;primaryColumns&quot;]-&gt;java.util.ArrayList[0]-&gt;org.apache.metamodel.jdbc.JdbcColumn[&quot;table&quot;]
  ......
  </code></pre>
  <p><strong>Java Code:</strong></p>
  <pre><code>DataContext dataContext = (JdbcDataContext)DataContextFactoryRegistryImpl.getDefaultInstance().createDataContext(properties);
  Schema selectedSchema = dataContext.getSchemaByName(&quot;schemaName&quot;);
  List&lt;Relationship&gt; relationships = new ArrayList(selectedSchema.getRelationships());
  </code></pre>