Hi,
once again me, I tried to understand your past posts, but I'm afraid I
didn't. I found a thread "Inheritance & delete" but I think I am missing
some posts and hence I do not understand the answers.
I'll repost my problem trying to be a little more explicit this time.
The tables:
CREATE CACHED TABLE Address (
adrOID VARCHAR(50) NOT NULL,
adrAttribute VARCHAR(50),
...
PRIMARY KEY (adrOID)
);
CREATE CACHED TABLE PersonAddress (
padOID VARCHAR(50) NOT NULL,
padAdditionalAttribute VARCHAR(50),
...
PRIMARY KEY (padOID)
);
The mapping:
<class-descriptor class="de.armax.sandbox.entity.Address"
table="Address">
<field-descriptor autoincrement="true" primarykey="true"
column="adrOID" jdbc-type="VARCHAR" name="oID"/>
<field-descriptor column="adrAttribute" jdbc-type="VARCHAR"
name="attribute"/>
...
</class-descriptor>
<class-descriptor class="de.armax.sandbox.entity.PersonAddress"
table="PersonAddress">
<field-descriptor autoincrement="true" primarykey="true"
column="padOID" jdbc-type="VARCHAR" name="oID"/>
<field-descriptor column="padAdditionalAttribute" jdbc-type="VARCHAR"
name="additionalAttribute"/>
...
<reference-descriptor
auto-delete="true"
auto-update="true"
name="super"
class-ref="de.armax.sandbox.entity.Address">
<foreignkey field-ref="oID"/>
</reference-descriptor>
</class-descriptor>
The first part of Java-code:
// create the broker, etc
...
// create and store person address
PersonAddress pad = new PersonAddress();
pad.setAttribute("Attribute");
pad.setAdditionalAttribute("Additional attribute");
broker.store(pad);
// create and store address
Address adr = new Address();
adr.setAttribute("Simple address");
broker.store(adr);
The second part of Java-code:
for (Iterator iter =
broker.getIteratorByQuery(QueryFactory.newQuery(Address.class, new
Criteria()));iter.hasNext();) {
Object o = iter.next();
logger.info("Found instance of " + o.getClass().getName());
broker.delete(o);
}
The problem:
The first part of Java-code executes the following SQL statements (having
exactly the result I am expecting):
INSERT INTO Address (adrOID,adrAttribute,adrOrderOID) VALUES
('A1CCAA3F-2E19-71E6-15F1-852ADB0D12C8','Attribute','')
INSERT INTO PersonAddress (padOID,padAdditionalAttribute,padPersonOID)
VALUES ('A1CCAA3F-2E19-71E6-15F1-852ADB0D12C8','Additional attribute','')
INSERT INTO Address (adrOID,adrAttribute,adrOrderOID) VALUES
('56F48112-07C4-BCB3-F16F-AA4FD39AE564','Simple address','')
The second part of Java-code produces the following log messages:
INFO [OjbMain.java Line:85] Found instance of
de.armax.sandbox.entity.Address (OID: 56F48112-07C4-BCB3-F16F-AA4FD39AE564)
INFO [OjbMain.java Line:85] Found instance of
de.armax.sandbox.entity.Address (OID: A1CCAA3F-2E19-71E6-15F1-852ADB0D12C8)
And here is the Proble. I expected one instance of Address and one instance
of PersonAddress. The delete statements do of course not delete the entry in
the PersonAddress table as OJB does not know that one of the two Address
objects corresponds to a person address.
I tried to add an <extent-class> tag to the mapping for address resulting in
a StackOverflow error (I found some posts about this in the list archive but
just wanted to try it before posting). I also tried changing the auto-***
attributes of the super-reference-descriptor. Didn't help either.
I hope that after this more detailed description of my scenario anyone can
provide help or hints. I can't imagine that I am the first one trying this
:-).
Regards,
Peter
P.S.: Balza, what kind of mapping to you use to map your inheritance
hierarchies? I used to use table per concrete class mapping and everything
works fine. But I need joined-table per subclass for compatibility reasons
and I do not get it work.
> Hello Peter,
> I've worked with inheritance and all works well (with some help of the
> mailing
> list). You shoud look at my past post or you should post your complete
> java code.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]