Within our application, we need to access data that's stored in two separate schemas
in an Oracle database. I've set up my repository.xml file with two
connection-descriptors, one for each schema. Both have a different jcd-alias assigned
to them. At runtime, when I create a PersistenceBroker, I build a PBKey that includes
the appropriate jcd-alias so that the correct schema is accessed.
Here's the problem. There are several cases where a table with the same name is
present in both schemas. Here is the snippet from two of the class-descriptors:
<class-descriptor class="com.ge.ps.pdb.ItoRegionData" table="ITO_REGN">
<field-descriptor [snip]>
</class-descriptor>
<class-descriptor class="com.ge.ps.cosmos.ItoRegionData" table="ITO_REGN">
<field-descriptor [snip]>
</class-descriptor>
The first table is in the "pdb" schema. The second is in the "cosmos" schema. Here's
the basics of the code that I'm using to get a list of records from the ITO_REGN table
in the 'cosmos' schema:
PBKey key = new PBKey("cosmos","cosmos","cosmos");
PersistenceBroker broker =
PersistenceBrokerFactory.createPersistenceBroker(key)
Query query =
new QueryByCriteria(com.ge.ps.pdb.data.ItoRegionData.class, null);
Collection theList =
broker.getCollectionByQuery(query);
In this case, I'm only interested in getting a list of records from the ITO_REGN table
in the 'cosmos' schema. However, since both class-descriptors above have the same
value for the 'table' attribute, OJB combines the column lists from both
class-descriptors when it builds the SQL statement. This makes perfect sense in
situations where you have multiple classes mapped to the same table. However, in my
case, I have different classes mapped to different tables. They have the same table
name, but they're in different schemas.
IMO, the best solution is to provide a more definitive way of uniquely identifying
individual tables beyond using just the table name. Since this problem would only
manifest itself when multiple connection-descriptors were present in the repository,
the simplest solution may be to include the jcd-alias from the corresponding
connection-descriptor in a new attribute on the class-descriptor for each table. If
this new attribute were set at the class-descriptor level, then it would be used in
addition to the table name in order to figure out which classes were mapped to the
same table.
Any thoughts?
Ron Gallagher
Atlanta, GA
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>