Gibbs, Tim wrote:
> OK, so your response below definately answered my question as to why it was
> fetching and I appreciate the very quick response.
>
> Now I have a more troubling problem with regards to using multiple databases
> and it seems to be exposed by QueryByCriteria(Object exampleObj);
>
> Let me explain: Suppose we have the following:
>
> repository.xml:
> ---------------
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE descriptor-repository SYSTEM "repository.dtd" [
> <!ENTITY user SYSTEM "repository_user.xml">
> <!ENTITY junit SYSTEM "repository_junit.xml">
> <!ENTITY internal SYSTEM "repository_internal.xml">
> <!ENTITY farAway SYSTEM "repositoryFarAway_user.xml">
> ]>
>
> <descriptor-repository version="0.9.5" isolation-level="read-uncommitted">
>
> <jdbc-connection-descriptor
> .....<!-- Assume this is properly defined POINTS TO DB#1--->
> />
> <!-- include user defined mappings here -->
> &user;
> <!-- include ojb internal mappings here -->
> &internal;
> <!-- user data of farAway db -->
> &farAway;
> </descriptor-repository>
>
> ________________
>
> Now if I look at repositoryFarAway_user.xml I see the following:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Defines the repository for a second database -->
>
> <!-- defining entities for include-files -->
> <!DOCTYPE descriptor-repository SYSTEM "repository.dtd" [
> <!ENTITY farAway SYSTEM "repositoryFarAway_user.xml">
> ]>
>
> <descriptor-repository version="0.9.5" isolation-level="read-uncommitted">
> <!-- The Default JDBC Connection. If a class-descriptor does not specify its
> own JDBC Connection,
> the Connection specified here will be used. -->
>
>
> <!-- This was my second far away db -->
> <jdbc-connection-descriptor
> platform="Hsqldb"
> jdbc-level="2.0"
> driver="org.hsqldb.jdbcDriver"
> protocol="jdbc"
> subprotocol="hsqldb"
> dbalias="../OJB_FarAway"
> username="sa"
> password=""
> />
>
> <!-- user data of farAway db -->
> &farAway;
>
> </descriptor-repository>
>
The file you quote is repositoryFarAway.xml !
Not repositoryFarAway_user.xml !
repositoryFarAway_user.xml can be include without problems:
<!-- user data for second database -->
<class-descriptor
class="org.apache.ojb.broker.FarAwayClass"
table="FAR_AWAY">
<field-descriptor id="1"
name="id"
column="ID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor id="2"
name="name"
column="NAME"
jdbc-type="VARCHAR"
/>
<field-descriptor id="3"
name="description"
column="DESCRIPTION"
jdbc-type="VARCHAR"
/>
</class-descriptor>
> How the heck does this supposed to parse??? Actually, in my case it is not
> parsing properley when the QueryByCriteria(Object refObject) is called.
> Here is why I don't think it should parse:
>
> The repository.dtd contains the following definition:
>
> <!ELEMENT descriptor-repository (jdbc-connection-descriptor,
> class-descriptor+)>
>
> But the examples suggest that we are going to have a root element
> <descriptor-repository> and then the &farAway; (in repository.xml) is going
> to insert another <descriptor-repository> element within that??
>
> Doesn't this violate the DTD??
>
yes it would! Maybe this is a bug in 0.9.5. At least in CVS HEAD it is
correct...
The 0.9.5 junit tests also don't show any bug...
> Is there a reason (other than having a huge file) that we can't put all the
> definitions in one file? One reason I can think of for this is that you
> CAN't (according the DTD) have more than on jdbc-connection-descriptor for a
> given repository (1 and only one per descriptor repository element and since
> that is the root element there should only be one of those.......
exactly!
there is one default repository containing (or including) *all* class
descriptors.
there can be other repositories containing subsets of these class
descriptors.
each subset repository is intended as an individual db
cheers,
Thomas
>
> I would love to hear someone else's comment on this.
>
> Thanks
>
> Tim
>
> -----Original Message-----
> From: Jakob Braeuchi [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 1:05 PM
> To: OJB Users List
> Subject: Re: QueryByExample not implemented???
>
>
> hi tim,
>
> query by example is actually a query by id (i'll rename it)
> for a minimal solution see QueryByCriteria(Object exampleObj);
>
> hth
> jakob
>
> ----- Original Message -----
> From: "Gibbs, Tim" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, September 20, 2002 6:48 PM
> Subject: QueryByExample not implemented???
>
>
>
>
> I was just attempting to perform a QueryByExample and have found that the
> QueryByExample object does not seem to have been completely implemented
> because the "getCriteria" method just returns null.
>
> Now my guess is that this should build Criteria from the example object
> passed into the constructor but clearly that is not the case.
>
> Is this mechanism actually working? It doesn't seem to be for me and I have
> checked to make sure the object being passed in is non-null and has
> attributes set. What I get back is ALL the rows of the table (as objects of
> course). Sample code below
>
> Thanks for any help.
> Cheers,
> Tim
>
>
> PersistenceBroker broker = null;
> try {
> broker = PersistenceBrokerFactory.createPersistenceBroker(new
> PBKey("my_repository.xml"));
>
> Query query;
> if(refIndex == null)
> query = null;
> else
> query = new QueryByExample(refIndex);
>
> Criteria crit = query.getCriteria();
> return broker.getCollectionByQuery(query);
>
> } catch (Throwable t) {
> t.printStackTrace();
> }
>
> --------------------------------------------
> Tim Gibbs
> RBC Capital Markets
> Phone: (416) 842-4663
> E-Mail: [EMAIL PROTECTED]
>
>
>
> <font face="Times New Roman" size="3">
> <p>-------------------------------------------------------------------------
> -----</p>
> <p> This e-mail may be privileged and/or confidential, and the sender does
> not waive any related rights and obligations. Any distribution, use or
> copying of this e-mail or the information it contains by other than an
> intended recipient is unauthorized. If you received this e-mail in error,
> please advise me (by return e-mail or otherwise) immediately.</p>
> <p> Ce courriel est confidentiel et prot�g�. L'exp�diteur ne renonce pas aux
> droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou
> copie de ce message ou des renseignements qu'il contient par une personne
> autre que le (les) destinataire(s) d�sign�(s) est interdite. Si vous recevez
> ce courriel par erreur, veuillez m'en aviser imm�diatement, par retour de
> courriel ou par un autre moyen.</p>
> <p>====================================================</p>
> </font>
>
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
> <font face="Times New Roman" size="3">
> <p>------------------------------------------------------------------------------</p>
> <p> This e-mail may be privileged and/or confidential, and the sender does not waive
>any related rights and obligations. Any distribution, use or copying of this e-mail
>or the information it contains by other than an intended recipient is unauthorized.
>If you received this e-mail in error, please advise me (by return e-mail or
>otherwise) immediately.</p>
> <p> Ce courriel est confidentiel et prot�g�. L'exp�diteur ne renonce pas aux droits
>et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce
>message ou des renseignements qu'il contient par une personne autre que le (les)
>destinataire(s) d�sign�(s) est interdite. Si vous recevez ce courriel par erreur,
>veuillez m'en aviser imm�diatement, par retour de courriel ou par un autre moyen.</p>
> <p>====================================================</p>
> </font>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>