title: @Entity Relation between tables on different databases
body: <p>I'm new on Java Enterprise and JPA (Using EclipseLink JPA 2.0 from Netbeans).
  I'm trying to realize a link between different @Entity classes in different projects and packages, with no success.</p>
  
  <p>Database D1 has a table T1 and a Synonym T2 referencing table T2 on Database D2.</p>
  
  <p>So I create 2 projects(Jars):</p>
  
  <p>D1-jpa containing @Entity package1.T1.class and persistence.xml (mapping also T2)</p>
  
  <p>D2-jpa containing @Entity package1.T2.class and persistence.xml</p>
  
  <p>I need to create a @OneToOne relation from T1 to T2 so that T1 has</p>
  
  <p>@OneToOne</p>
  
  <p>public T2 t2;</p>
  
  <p>The problem is when I try to execute the simple JPQL query:</p>
  
  <p>SELECT t FROM T1 t</p>
  
  <p>The translated query is something like</p>
  
  <p>SELECT t.field1, t.field2 , T2_t2 FROM T1 t; -- "T2_t2"??</p>
  
  <p>when I expected something as
  SELECT t1.field1, t1.field2, t2.field1 FROM T1 t1, T2 t2 </p>
  
  <p>WHERE (join condition)</p>
  
  <p>What's your solutions to the problem? What if synonym on D1 has different names from the real Table on D2 (Synonym TT2 referencing T2 on D2 ...)?</p>
  
  <p>Regard all.</p>
  
  <p>F.</p>