openjpa-users mailing list archives

Hi,
I'm sorry, I looked at the log file that I attached and realized that it has
gotten truncated due to some character in between (I copy pasted it from
eclipse console). Here is the entire log file on a different run.
Pinaki, your observation is correct but the thing is the very reason that
the constraint gets violated is because instead of generating the Customer
insert and the Creditor insert, the framework generates two creditor inserts
(for any ID - 648 in this case) leading to key violations on the database.
If it were firing the proper inserts, this wouldn't be the case.
In the attached log you'll see that the first set of inserts is correct (ID
1217). However for the second set of inserts, it fires the Creditor insert
query twice as opposed to Customer and then Creditor (ID 1216) and this
leads to the violation.
I find no visible reason for this to happen. Here is my calling code.
package dk.pbs.bs.dao.unittests;
import java.util.Date;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
public class BaseDAOTest {
public void testCreateInheritance() {
System.out.println("testInheritacne");
EntityManager manager = null;
Creditor creditor = new Creditor(new Double(1216), new Double(659),
"DK3", new Date(), new Date(), new Date(), "PROG", new Date());
try {
//Invocations to the processing logic
manager = FactoryTest.factory.createEntityManager();
EntityTransaction transaction = manager.getTransaction();
transaction.begin();
BaseDAO.create(manager, creditor);
transaction.commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
manager.close();
}
}
public void testCreateManyToOne() {
System.out.println("manytoone");
EntityManager manager = null;
Creditor creditor = new Creditor(new Double(1217), new Double(126),
"DK3", new Date(), new Date(), new Date(), "PROG", new Date());
try {
//Invocations to the processing logic
manager = FactoryTest.factory.createEntityManager();
EntityTransaction transaction = manager.getTransaction();
transaction.begin();
BaseDAO.create(manager, creditor);
transaction.commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
manager.close();
}
}
public static void main(String[] args) {
BaseDAOTest test = new BaseDAOTest();
test.testCreateManyToOne();
test.testCreateInheritance();
}
}
The identity generation strategy at this point is "assigned"(to borrow a
hibernate term, haven't looked up the equivalent openJPA term). So at this
point, I'm just hard coding unique ID's. Will change this in the future once
I get a handle on all kinds of relationships working properly.
HTH... Hope to hear from someone soon.
Pinaki Poddar wrote:
>
>> Can someone please confirm that Inheritance JOINED works?
> Yes.
>
> Many of the insert statements for CREDITOR in the log shows PBS_NO 668.0.
> No wonder DB2 is complaining about SQL ERROR 23505 which is violation of
> database unique constraint as PBS_NO happens to be the primary key.
>
> What are the persistence identity value generation strategies employed by
> Customer and Creditor class?
>
>
>
>
>
>
http://n2.nabble.com/file/n788679/updatedlog.log updatedlog.log
--
View this message in context: http://n2.nabble.com/problem-when-persist-object-using-JOINED-inhertitance-under-1.1.0-tp580291p788679.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.