In a word: no. There is no straight forward way to do what you want to 
accomplish.

Obviously you can manage that yourself by setting the value to the size of the 
collection before saving, and then having that field in the database.

At first I thought a field conversion might work, but it has no context to look 
at other fields.

You can write a custom row reader for this object type that looks at the other 
field and populates the size variable. But you are still going to have to 
manage that field yourself when the collection is mutated.

Take a look at:

org.apache.ojb.broker.accesslayer.RowReader

-Andrew


-----Original Message-----
From: Andrey Shulinskiy [mailto:[EMAIL PROTECTED]
Sent: Mon 8/8/2005 9:01 PM
To: [email protected]
Subject: OJB  question - "reference counter" field
 
Hi there!

I am quite new to OJB and I'd really appreciate if anybody could help me
with the following issue.

The case is rather simple:
tables A and B have the 1 - N relationship. And I want the objects of the
class A have not the collection of the related objects B but just the number
of such objects:

class A {
...
        private Integer bCounter;
...
}

So the questions are - is it possible in OJB and if it is then how could it
be done? Is it just some kind of mapping ore something more complicated?
Thanks.

Yours sincerely,
Andrey Shulinskiy.


---------------------------------------------------------------------
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