I don't think its the db.load() cache that is causing the problem that I'm
seeing because I see the problem with the first call to db.load(). If you
look a the code snippet below it better explains my problem. What I do is to
create two JDO objects jdo1 and jdo2 which correspond to different mapping
files. The mapping file of the jdo1 object specifies a relationship between
DirectoryNodes and FileNodes, the mapping file of the jdo2 object does not.
When I call the db2.load() I expect to just get the DirectoryNode but what I
get is the DirectoryNode and all the associated FileNodes. Its acts like I
actually called the db1.load(). If I reverse the order of the creation of
db1 and db2 in the try clause then I when I call db2.load() I get the
expected behavior but when I call db1.load() I get the behavior of the
db2.load(). Basically the first Database object that is instantiated sets
the behavior of all other Database objects that are instantiated even if the
Database objects are from different JDO objects pointing to different
mapping files. I have set the cache to none in the mapping file and am
seeing the same behavior. Do you have any other suggestions that I can try
to get around the problem that I'm seeing.
Thanks
Tom
JDO jdo1 = new JDO();
jdo1.setDatabaseName("test");
jdo1.setConfiguration("my_database.xml");
Database db1 = null;
JDO jdo2 = new JDO();
jdo2.setDatabaseName("test");
jdo2.setConfiguration("my_database2.xml");
Database db2 = null;
try
{
db1 = jdo1.getDatabase();
db2 = jdo2.getDatabase();
}
catch (Exception e)
{
System.out.println("Error getting database exception is " + e);
e.printStackTrace();
}
DirectoryNode dirNode = (DirectoryNode)db2.load(DirectoryNode.class,
nodeName);
-----Original Message-----
From: Patrick van Kann [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 4:43 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Multiple JDO objects with different mapping
files
Castor uses a caching mechanism that would probably account for the
behaviour you are experiencing. The cache of the first JDO is invisible
to the second, and vice-verse. When you use the db.load() method, the
object will be loaded from the cache if it has been previous loaded. If
you use an OQL query, then the cache is not used.
It is possible to set cache-type to "none" in the mapping, though this
may not solve all of your problems if you have a high degree of
concurrency. If the 2 JDO objects are both trying to update rows in the
database simultaneously, you may get errors associated with the
detection of dirty reads/writes.
I hope this helps.
Patrick
HAMMELL,THOMAS (HP-NewJersey,ex2) wrote:
> I'm trying to use multiple JDO objects to access the same database in
> different ways. I have a database that I'm using to represent
> directories and files in a file system. I have two tables a directory
> table and a file table. In some operations when I load a directory I
> want to load all the corresponding files that are children of the
> directory. For other operations when I load a directory I don't want
> to load the corresponding files. To do this I created two mapping
> files one that specifies the relation between the directories and
> files and one that doesn't. I then created two JDO objects one
> corresponding to each mapping file. The problem is that both JDO
> objects give the same results when I retrieve a directory. For
> example I first create the JDO object which corresponds to the mapping
> file that defines a relation between the directories and files then I
> create the JDO object that corresponds to the mapping file that
> doesn't have a relationship between directories and files. If I use
> the second JDO object to retrieve a directory I get its corresponding
> files for some reason even though the second JDO object doesn't know
> the relationship between directories and files. If I create the JDO
> objects in the opposite order then I get the opposite behavior. It
> almost seems that there is some kind of caches that is happening that
> is preventing the second JDO object from being created correctly. Is
> this a know problem and if so how do I get around it. If it is not a
> know problem then I would like to add it to the bug list. If I did
> not explain the problem properly and you need more explanation let me
> know. I have a complete example that shows the problem.
>
>
> Thanks
> Tom
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev