Testing complex object graphs with circular and bidirectional references when
using database foreign key settings (without support of deferred foreign keys).
The classes hierarchy looks like:
Class Shop has a bidirectional 1:1 reference with ShopDetail.
Shop has a 1:n relation with Product, Product has a 1:1 reference to Shop.
Shop has a m:n relation with Distributor.
Product has a 1:n relation to itself to handle sub-Products.
In the database the following foreign keys are declared:
- Shop has a FK to ShopDetail
- Product has a FK to Product
- Product has a FK to Shop
- CT_SHOP_DISTRIBUTOR indirection table has FK's to Shop and Distributor
Here a summery of the dependencies:
Shop--1:1-->ShopDetail--1:1-->Shop
Shop--1:n-->Product--1:1-->Shop
Product--1:n-->Product
Shop--m:n-->Distributor
Class ObjectA has a 1:1 reference to ObjectAA,
ObjectAA has 1:1 to ObjectAAA,
ObjectAAA has 1:1 to ObjectA and to ObjectAAAA,
ObjectAAAA has 1:1 to ObjectA
- ObjectA has FK to ObjectAA
- ObjectAA has FK to ObjectAAA
- ObjectAAA has FK to ObjectAAAA
Here a summery of the dependencies:
ObjetA--1:1-->ObjectAA--1:1-->ObjectAAA--1:1-->ObjectA
ObjetA--1:1-->ObjectAA--1:1-->ObjectAAA--1:1-->ObjectAAAA--1:1-->ObjectA
version: $Id: CircularTest.java,v 1.1.2.10 2005/12/21 22:31:28 tomdz Exp $
Inner Class :public static class Shop
Inner Class :public static class Distributor
Inner Class :public static class Product
Inner Class :public static class ShopDetail
Inner Class :abstract static class BaseObject
Inner Class :public static class ObjectA extends BaseObject
Inner Class :public static class ObjectAA extends BaseObject
Inner Class :public static class ObjectAAA extends BaseObject
Inner Class :public static class ObjectAAAA extends BaseObject
testBidirectionalWithConstraint_1e() Handle circular 1:1 by using a 'constraint'-flag property in
reference-descriptor to make OJB's ordering algorithm more
sophisticated.
public void
testBidirectionalWithConstraint_2a() Class Shop has a bidirectional 1:1 reference with ShopDetail
(FK constraint from SHOP to SHOP_DETAIL table).
public void
testBidirectionalWithConstraint_2b() Class Shop has a bidirectional 1:1 reference with ShopDetail and the DB table of Shop
has a foreign key constraint on ShopDetail table.
public void
testBidirectionalWithConstraint_2d() Class Shop has a bidirectional 1:1 reference with ShopDetail and the DB table of Shop
has a foreign key constraint on ShopDetail table.
public void
testCircularOneToN_1() Handling circular 1:n references with FK settings and use of
auto-delete setting to delete object graph.
public void
testCircularOneToN_2() Handling circular 1:n references with FK settings and use of
auto-delete setting to delete object graph.
public void
testCircularOneToN_3() Handling circular 1:n references with FK settings and use of
auto-delete setting to delete object graph.
public void
testCircularOneToOne_1a() Test show handling with circular references and database FK settings.
public void
testCircularOneToOne_1b() Test show handling with circular references and database FK settings.
public void testAutoDeleteEnabledNonCircular() throws Exception(Code)
Use auto-delete setting to delete object graph.
testBidirectionalWithConstraint_1a
public void testBidirectionalWithConstraint_1a() throws Exception(Code)
Handle circuler 1:1 with default methods.
testBidirectionalWithConstraint_1b
public void testBidirectionalWithConstraint_1b() throws Exception(Code)
Define order of object operations using flush() method.
testBidirectionalWithConstraint_1c
public void testBidirectionalWithConstraint_1c() throws Exception(Code)
If the user take care of the ordering itself the test pass.
testBidirectionalWithConstraint_1d_PB
public void testBidirectionalWithConstraint_1d_PB() throws Exception(Code)
This test is only for comparison of ODMG- with PB-api. It's not recommended
to do this in ODMG production environment.
throws: Exception -
testBidirectionalWithConstraint_1e
public void testBidirectionalWithConstraint_1e() throws Exception(Code)
Handle circular 1:1 by using a 'constraint'-flag property in
reference-descriptor to make OJB's ordering algorithm more
sophisticated.
testBidirectionalWithConstraint_2a
public void testBidirectionalWithConstraint_2a() throws Exception(Code)
Class Shop has a bidirectional 1:1 reference with ShopDetail
(FK constraint from SHOP to SHOP_DETAIL table).
Shop has a m:n relation with Distributor.
testBidirectionalWithConstraint_2b
public void testBidirectionalWithConstraint_2b() throws Exception(Code)
Class Shop has a bidirectional 1:1 reference with ShopDetail and the DB table of Shop
has a foreign key constraint on ShopDetail table. Shop has a m:n relation with Distributor.
If the user take care of the ordering itself the test pass.
testBidirectionalWithConstraint_2d
public void testBidirectionalWithConstraint_2d() throws Exception(Code)
Class Shop has a bidirectional 1:1 reference with ShopDetail and the DB table of Shop
has a foreign key constraint on ShopDetail table. Shop has a m:n relation with Distributor.
If the user take care of the ordering itself the test pass.
public void testCircularOneToOne_1dd() throws Exception(Code)
Do manually ordering using in conjunction with OJB's ordering.
testCircularOneToOne_1e
public void testCircularOneToOne_1e() throws Exception(Code)
testCircularOneToOne_2a
public void testCircularOneToOne_2a() throws Exception(Code)
User take care of the ordering itself.
testCircularOneToOne_PB_a
public void testCircularOneToOne_PB_a() throws Exception(Code)
This test is only for comparison of ODMG- with PB-api. It's not recommended
to do this in ODMG production environment.
Handling of circular 1:1 reference: ObjetA--1:1-->ObjectAA--1:1-->ObjectAAA--1:1-->ObjectA
when each object has a FK constraint to it's reference.
throws: Exception -
testCircularOneToOne_PB_b
public void testCircularOneToOne_PB_b() throws Exception(Code)
This test is only for comparison of ODMG- with PB-api. It's not recommended
to do this in ODMG production environment.
Handling of circular 1:1 reference: ObjetA--1:1-->ObjectAA--1:1-->ObjectAAA--1:1-->ObjectA
when each object has a FK constraint to it's reference.
throws: Exception -
testCircularWithAutoDeleteEnabled
public void testCircularWithAutoDeleteEnabled() throws Exception(Code)
Use auto-delete setting to delete object graph.
testMtoNWithBackReference_2
public void testMtoNWithBackReference_2() throws Exception(Code)
testOneToNWithSelfReference_1
public void testOneToNWithSelfReference_1() throws Exception(Code)
testOneToNWithSelfReference_2
public void testOneToNWithSelfReference_2() throws Exception(Code)
testOneToNWithSelfReference_3
public void testOneToNWithSelfReference_3() throws Exception(Code)
testOneToOneWithBackReference_1
public void testOneToOneWithBackReference_1() throws Exception(Code)
testOneToOneWithBackReference_2
public void testOneToOneWithBackReference_2() throws Exception(Code)
testOneToOneWithBackReference_3
public void testOneToOneWithBackReference_3() throws Exception(Code)
Fields inherited from org.apache.ojb.junit.ODMGTestCase