You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Charles N. Harvey III" <ch...@alloy.com> on 2004/02/09 20:17:11 UTC

Inner Join on separate tables

Hello.
I was wondering if it was possible to join two objects that are
mapped to two separate DBs.

SELECT p.name, p.email, e.title, e.position
FROM users.dbo.PERSON AS p
INNER JOIN office.dbo.EMPLOYEES AS e ON e.employee_id = p.person_id
WHERE e.title = 'Manager'

<class-descriptor
  class="com.mycom.users.om.Person"
  table="PERSON">
  <field-descriptor
    name="id"
    column="person_id"
    jdbc-type="INTEGER"
    primarykey="true"
    access="readwrite"/>
  <field-descriptor
    name="name"
    column="name"
    jdbc-type="VARCHAR"
    access="readwrite"/>
  <field-descriptor
    name="email"
    column="email"
    jdbc-type="VARCHAR"
    access="readwrite"/>
  <field-descriptor
    name="employeeId"
    column="employee_id"
    jdbc-type="INTEGER"
    access="anonymous"/>
  <reference-descriptor
    name="employee"
    class-ref="com.mycom.office.om.Employee">
    <foreignkey
      field-ref="employeeId"/>
  </reference-descriptor>
</class-descriptor>
<class-descriptor
  class="com.mycom.office.om.Employee"
  table="EMPLOYEE">
  <field-descriptor
    name="id"
    column="employee_id"
    jdbc-type="INTEGER"
    primarykey="true"
    access="readwrite"/>
  <field-descriptor
    name="title"
    column="title"
    jdbc-type="VARCHAR"
    access="readwrite"/>
  <field-descriptor
    name="position"
    column="position"
    jdbc-type="INTEGER"
    access="readwrite"/>
</class-descriptor>

I have two connection descriptors in my repository.xml.  Should I
change the table="EMPLOYEE" with table="office.dbo.EMPLOYEE"?

Can this be done.  There is a very good chance that my mappings
are not done correctly.

Any help is much appreciated.


Charlie


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Inner Join on separate data bases

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
Sorry, that is supposed to be "inner join on separate data bases".
D'oh.


Charlie


Charles N. Harvey III wrote:

> Hello.
> I was wondering if it was possible to join two objects that are
> mapped to two separate DBs.
>
> SELECT p.name, p.email, e.title, e.position
> FROM users.dbo.PERSON AS p
> INNER JOIN office.dbo.EMPLOYEES AS e ON e.employee_id = p.person_id
> WHERE e.title = 'Manager'
>
> <class-descriptor
>  class="com.mycom.users.om.Person"
>  table="PERSON">
>  <field-descriptor
>    name="id"
>    column="person_id"
>    jdbc-type="INTEGER"
>    primarykey="true"
>    access="readwrite"/>
>  <field-descriptor
>    name="name"
>    column="name"
>    jdbc-type="VARCHAR"
>    access="readwrite"/>
>  <field-descriptor
>    name="email"
>    column="email"
>    jdbc-type="VARCHAR"
>    access="readwrite"/>
>  <field-descriptor
>    name="employeeId"
>    column="employee_id"
>    jdbc-type="INTEGER"
>    access="anonymous"/>
>  <reference-descriptor
>    name="employee"
>    class-ref="com.mycom.office.om.Employee">
>    <foreignkey
>      field-ref="employeeId"/>
>  </reference-descriptor>
> </class-descriptor>
> <class-descriptor
>  class="com.mycom.office.om.Employee"
>  table="EMPLOYEE">
>  <field-descriptor
>    name="id"
>    column="employee_id"
>    jdbc-type="INTEGER"
>    primarykey="true"
>    access="readwrite"/>
>  <field-descriptor
>    name="title"
>    column="title"
>    jdbc-type="VARCHAR"
>    access="readwrite"/>
>  <field-descriptor
>    name="position"
>    column="position"
>    jdbc-type="INTEGER"
>    access="readwrite"/>
> </class-descriptor>
>
> I have two connection descriptors in my repository.xml.  Should I
> change the table="EMPLOYEE" with table="office.dbo.EMPLOYEE"?
>
> Can this be done.  There is a very good chance that my mappings
> are not done correctly.
>
> Any help is much appreciated.
>
>
> Charlie
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org