Hi Alen,

You have to tell OJB that there is an inheritance hierarchy.
You do it by defining extents.
There is an example for this in repository_junit.xml.
Have a look at definitions for classes Article, BookArticle, CdArticle.

cheers,
Thomas

Alen Ribic wrote:
Hi all

I have a bit of a problem with inheritance in my application when it comes
to storing persistent objects using OJB.

I am using Struts in combination with OJB.
What I have now is a JavaBean "User" and I have a direct subclass
"RegisterForm".
What I wanna do is use RegisterForm as my FormBean and at runtime I wish to
reference a User type reference and store that in my db. So, I would like to
reuse the setters/getters of my User bean where necessary for Struts
purpose. (Any form where user's setters/getters are needed)
My OJB XML repository contains mapping for User Bean to User relational
table.

So, now the problem is as follows:

...
User user = null;
user = (User)request.getAttribute("registerForm");
...
PersistenceBroker broker = null;
try {
   broker = PersistenceBrokerFactory.
   defaultPersistenceBroker();
   broker.beginTransaction();
   broker.store(user);
   broker.commitTransaction();
} catch(Throwable exc) {
 ...
}
...

In the above code snippet, "request.getAttribute("registerForm");", returns
an instance of RegisterForm class. (Then I cast to User type...)
As soon as store(...) method is fired, ClassNotPersistenceCapableException
is thrown indicating that za.co.alen.struts.RegisterForm class is not found
in OJB Repository.

I need OJB system to reference RegisterForm classes direct superclass, in
this case User of course.

Any help on how I can overcome this problem will be much appreciated.

Thanks,
--Alen



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