Another observation is that if I'm persisting a base class subclass hierarchy twice in two methods, like I'm doing, the first invocation fails. However openJPA now understands the inheritance hierarchy properly and the subsequent call succeeds with openJPA firing the inserts in the proper order.
I stand corrected. The above observation is incorrect as I have today discovered that the behaviour is well and truly random. Sometimes openJPA fires queries in the correct order, sometimes it fires queries for the child class twice instead of parent class first and child class later. I also tried using an orm.xml (instead of annotations) without any success. Here is my database schema... create table <SCHEMA>.CUSTOMER ( PBS_NO DECIMAL(8) not null, CVR_NO DECIMAL(8) not null, SP_NO DECIMAL(10), BP_NO DECIMAL(10), BP_NO_OWNER CHAR(4), HREG_NO DECIMAL(4), PREFIX CHAR(10), NAME1 VARCHAR(70), NAME2 VARCHAR(70), ADDR1 VARCHAR(70), ADDR2 VARCHAR(70), ADDR3 VARCHAR(70), POSTAL_CD CHAR(10) not null, CITY VARCHAR(70), COUNTRY_CD CHAR(2), LANG_CD CHAR(4), START_DT DATE not null, VAL_START_DT DATE not null, VAL_END_DT DATE not null, UPDATE_BY CHAR(10) not null, UPDATE_TS TIMESTAMP not null, constraint PK_CU primary key (PBS_NO) ); create table <SCHEMA>.CREDITOR ( PBS_NO DECIMAL(8) not null, CRED_TYPE VARCHAR(20) not null, BILLING_TYPE CHAR(4) not null, PREMIUM_CUST_FLG CHAR(1), START_DT DATE not null, VAL_START_DT DATE not null, VAL_END_DT DATE not null, UPDATE_BY CHAR(10) not null, UPDATE_TS TIMESTAMP not null, constraint PK_CR primary key (PBS_NO) ); alter table <SCHEMA>.CREDITOR add constraint F_FK_CU foreign key (PBS_NO) references <SCHEMA>.CUSTOMER (PBS_NO) on delete no action; devu213 wrote: > > Subsequent to my last post, I have tried the code on versions 1.0.2 and > 1.2.0. It fails on both ( in addition to 1.1.0 on which I originally tried > it). > > Another observation is that if I'm persisting a base class subclass > hierarchy twice in two methods, like I'm doing, the first invocation > fails. However openJPA now understands the inheritance hierarchy properly > and the subsequent call succeeds with openJPA firing the inserts in the > proper order. > > This seemingly trivial piece of code is giving me a lot of strife not to > mention the fact that I went on a wild goose chase thinking the problem > lay somewhere else. > > Can someone please help me out here ?? I have attached my SQL trace log > which should give some pointers. > > Is Inheritancetype.JOINED working for anyone with any version. Can someone > please verify and tell me what I'm doing wrong ? > http://n2.nabble.com/file/n781623/openjpa.log openjpa.log > > > > > Acton Wang wrote: >> >> >> hi, >> >> I used 1.1.0 to try to implement a simple JOINED inhertance using >> orm.xml: >> >> >> <entity class="Parent"> <table name="Parent"/> <inheritance >> strategy="JOINED"/> <attributes> <id name="partyID"> <column >> name="PARTYID" column-definition="VARCHAR(200)" nullable="false"/> >> </id> >> ... </attributes> </entity> <entity class="Child"> <table >> name="Child"/> <primary-key-join-column name="PARTYID" >> referenced-column-name="PARTYID"/> <attributes> <basic >> name="fullRegisteredName"> <column name="FULLREGISTEREDNAME" >> column-definition="VARCHAR(200)" updatable="true" insertable="true"/> >> </basic> ..... >> >> when I try to persist multiple Child objects, the first one would be >> ok but the following ones will fail and from trace, it seems that it >> keeps inserting into the "Child" table 2 times instead of being inserting >> Parent table first then Child table. >> >> It looks no problem if I run it under 1.0.2 version. Is it a bug? >> >> Thx >> Acton >> > > -- View this message in context: http://n2.nabble.com/problem-when-persist-object-using-JOINED-inhertitance-under-1.1.0-tp580291p783275.html Sent from the OpenJPA Users mailing list archive at Nabble.com.