Hi Armin, thanks for your response.
I think I have a bug in my code too... :)
I am using 1.0.0, should I upgrade?

I'd be happy to send you the full project, it contains a bunch of persistence-capable classes and a single maven test case, of which I have posted the code.

Here are things I wonder about:

I am recreating the implementation and the database before the query, so I do this:
impl = OJB.newInstance()
db = impl.newDatabase();
db.open();
tx = impl.newTransaction();
tx.begin();
// INSERT CANDIDATE
tx.commit()
( I just think of this, I don't close the db.... mmm... probable cause? I'll check this next)
// RECREATE
impl = OJB.newInstance()
db = impl.newDatabase();
db.open()
tx = impl.newTransaction()
tx.begin
// DO QUERY
// LOG RESULTS
tx.commit()
// LOG RESULTS AGAIN


I never close the database (I think I read somewhere this is ok with ODMG? Or maybe not?)
I just make sure I commit/rollback the transaction and then let all objects go out of scope.


It is this way because I made an openDatabase function which is called from submitCandidate() and queryCandidates()

Is this way of approaching it fine by itself? Should I use another approach?

About the int and Integer, I use int. I did not try Integer, should I?
The funny thing is, the objects are inserted fine. If I remove the first section of the code that inserts the object, I get only null objects from the query. If I leave the insert code in, I get only the last object (The one I just inserted) back ok, the rest is null. I thought of caching, but ObjectCacheEmptyImpl made no difference.


Greetings,
-Stijn


Armin Waibel wrote:

Hi Stijn,

really strange. Checked your repository, seems ok. But there have to be a bug in your code (or improbable in OJB ;-)).Which version of OJB do you use? Did you try 1.0.1 or latest from CVS branch?
Seems that all found objects has id==0 - strange again. Do you use int or Integer type for PK/FK fields, did you try to use Integer?


regards,
Armin

Stijn de Witt wrote:

Anyone?


Stijn de Witt wrote:

Ok, I changed the cache settings in repository_database.xml to ObjectCacheEmptyImpl, like this:

<object-cache class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl"/>
<!--object-cache class="org.apache.ojb.broker.cache.ObjectCacheDefaultImpl">
<attribute attribute-name="timeout" attribute-value="900"/>
<attribute attribute-name="autoSync" attribute-value="true"/>
</object-cache-->


But it didn't help one bit....

-Stijn


Stijn de Witt wrote:

It's the strangest thing, if I remove the submit test and only do the query, NONE of the objects are ok...This smells like a caching problem to me...


Stijn de Witt wrote:

I am having a strange problem. I have a class Person, a class Candidate that extends Person and a class Address that has a many-to-one relationship with Person. I created a testcase that inserts a candidate with lastName=="Witt", with a homeAddress, and then does a query for all objects with that lastName. The first time everything seemed fine, but after repeated runs, although the object is inserted ok each time, and the query returns exactly the right number of objects, only the last object is materialized. The first objects have all fields set to NULL....? (The null fields in the last object are ok, I just never set them).

Could you look at the code and results below? I am sorry this has become a lengthy post.

Thanks in advance for any help,

-Stijn




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to