| 1 package org.apache.ojb.odmg; 2 3 17 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor; 24 import org.apache.ojb.broker.metadata.ClassDescriptor; 25 import org.apache.ojb.junit.ODMGTestCase; 26 import org.odmg.OQLQuery; 27 import org.odmg.Transaction; 28 29 69 public class CircularTest extends ODMGTestCase 70 { 71 public static void main(String [] args) 72 { 73 String [] arr = {CircularTest.class.getName()}; 74 junit.textui.TestRunner.main(arr); 75 } 76 77 81 public void testCircularOneToN_1() throws Exception  82 { 83 String name = "testCircularOneToN_1_" + System.currentTimeMillis(); 84 ojbChangeReferenceSetting(Product.class, "subProducts", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 85 86 Product p1 = new Product(name + "_p1"); 87 Product p2 = new Product(name + "_p2"); 88 Product p3 = new Product(name + "_p3"); 89 90 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 91 tx.begin(); 92 p1.addSubProduct(p2); 93 p2.addSubProduct(p3); 94 database.makePersistent(p3); 95 tx.flush(); 98 p3.addSubProduct(p1); 100 tx.commit(); 101 102 tx.begin(); 103 tx.lock(p3, Transaction.WRITE); 106 tx.setCascadingDelete(Product.class, "subProducts", false); 108 p3.setSubProducts(null); 109 tx.flush(); 110 database.deletePersistent(p3); 111 database.deletePersistent(p2); 112 database.deletePersistent(p1); 113 tx.commit(); 114 115 tx.begin(); 116 OQLQuery query = odmg.newOQLQuery(); 117 query.create("select objects from " + Product.class.getName() + " where name like $1"); 118 query.bind(name + "%"); 119 Collection result = (Collection ) query.execute(); 120 tx.commit(); 121 122 assertEquals(0, result.size()); 123 } 124 125 129 public void testCircularOneToN_2() throws Exception  130 { 131 String name = "testCircularOneToN_2_" + System.currentTimeMillis(); 132 ojbChangeReferenceSetting(Product.class, "subProducts", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 133 134 Product p1 = new Product(name + "_p1"); 135 Product p2 = new Product(name + "_p2"); 136 Product p3 = new Product(name + "_p3"); 137 Product p4 = new Product(name + "_p4"); 138 Product p5 = new Product(name + "_p5"); 139 Product p6 = new Product(name + "_p6"); 140 Product p7 = new Product(name + "_p7"); 141 142 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 143 tx.begin(); 144 p1.addSubProduct(p2); 145 p1.addSubProduct(p3); 146 p3.addSubProduct(p4); 147 p3.addSubProduct(p5); 148 p5.addSubProduct(p6); 149 p6.addSubProduct(p7); 150 database.makePersistent(p1); 151 tx.flush(); 154 p6.addSubProduct(p1); 156 tx.commit(); 157 158 tx.begin(); 159 tx.lock(p6, Transaction.WRITE); 162 tx.setCascadingDelete(Product.class, "subProducts", false); 163 p6.setSubProducts(null); 164 tx.flush(); 165 tx.setCascadingDelete(Product.class, "subProducts", true); 166 database.deletePersistent(p1); 167 tx.commit(); 168 169 tx.begin(); 170 OQLQuery query = odmg.newOQLQuery(); 171 query.create("select objects from " + Product.class.getName() + " where name like $1"); 172 query.bind(name + "%"); 173 Collection result = (Collection ) query.execute(); 174 tx.commit(); 175 176 assertEquals(1, result.size()); 179 Product p7_new = (Product) result.iterator().next(); 180 assertEquals(name + "_p7", p7_new.getName()); 181 } 182 183 187 public void testCircularOneToN_3() throws Exception  188 { 189 String name = "testCircularOneToN_3_" + System.currentTimeMillis(); 190 ojbChangeReferenceSetting(Product.class, "subProducts", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 191 192 Product p1 = new Product(name + "_p1"); 193 Product p2 = new Product(name + "_p2"); 194 Product p3 = new Product(name + "_p3"); 195 196 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 197 tx.begin(); 198 p1.addSubProduct(p2); 199 p2.addSubProduct(p3); 200 database.makePersistent(p3); 201 tx.flush(); 204 p3.addSubProduct(p1); 206 tx.commit(); 207 208 tx.begin(); 209 tx.lock(p3, Transaction.WRITE); 212 tx.setCascadingDelete(Product.class, "subProducts", false); 214 p3.setSubProducts(null); 215 tx.flush(); 216 tx.setCascadingDelete(Product.class, "subProducts", true); 219 database.deletePersistent(p1); 220 tx.commit(); 221 222 tx.begin(); 223 OQLQuery query = odmg.newOQLQuery(); 224 query.create("select objects from " + Product.class.getName() + " where name like $1"); 225 query.bind(name + "%"); 226 Collection result = (Collection ) query.execute(); 227 tx.commit(); 228 229 assertEquals(0, result.size()); 230 } 231 232 235 public void testCircularWithAutoDeleteEnabled() throws Exception  236 { 237 String name = "testCircularWithAutoDeleteEnabled_" + System.currentTimeMillis(); 238 239 ojbChangeReferenceSetting(ObjectA.class, "refAA", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 240 ojbChangeReferenceSetting(ObjectAA.class, "refAAA", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 241 ojbChangeReferenceSetting(ObjectAAA.class, "refAAAA", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 242 ojbChangeReferenceSetting(ObjectAAAA.class, "refA", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 243 244 ObjectA a = new ObjectA(name + "_ObjectA"); 245 ObjectAA aa = new ObjectAA(name + "_ObjectAA"); 246 ObjectAAA aaa = new ObjectAAA(name + "_ObjectAAA"); 247 ObjectAAAA aaaa = new ObjectAAAA(name + "_ObjectAAAA"); 248 a.setRefAA(aa); 250 aa.setRefAAA(aaa); 251 aaa.setRefAAAA(aaaa); 252 aaaa.setRefA(a); 253 254 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 255 tx.begin(); 256 database.makePersistent(a); 257 tx.commit(); 258 259 tx.begin(); 260 OQLQuery query = odmg.newOQLQuery(); 261 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 262 query.bind(name + "%"); 263 Collection result = (Collection ) query.execute(); 264 assertEquals(1, result.size()); 265 266 query = odmg.newOQLQuery(); 267 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 268 query.bind(name + "%"); 269 result = (Collection ) query.execute(); 270 assertEquals(1, result.size()); 271 272 query = odmg.newOQLQuery(); 273 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 274 query.bind(name + "%"); 275 result = (Collection ) query.execute(); 276 assertEquals(1, result.size()); 277 278 query = odmg.newOQLQuery(); 279 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 280 query.bind(name + "%"); 281 result = (Collection ) query.execute(); 282 assertEquals(1, result.size()); 283 tx.commit(); 284 285 tx.begin(); 286 291 tx.lock(aaaa, Transaction.WRITE); 292 aaaa.setRefA(null); 294 database.deletePersistent(a); 295 tx.commit(); 296 297 tx.begin(); 298 query = odmg.newOQLQuery(); 299 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 300 query.bind(name + "%"); 301 result = (Collection ) query.execute(); 302 assertEquals(0, result.size()); 303 304 query = odmg.newOQLQuery(); 305 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 306 query.bind(name + "%"); 307 result = (Collection ) query.execute(); 308 assertEquals(0, result.size()); 309 310 query = odmg.newOQLQuery(); 311 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 312 query.bind(name + "%"); 313 result = (Collection ) query.execute(); 314 assertEquals(0, result.size()); 315 316 query = odmg.newOQLQuery(); 317 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 318 query.bind(name + "%"); 319 result = (Collection ) query.execute(); 320 assertEquals(0, result.size()); 321 tx.commit(); 322 } 323 324 327 public void testAutoDeleteEnabledNonCircular() throws Exception  328 { 329 String name = "testAutoDeleteEnabledNonCircular_" + System.currentTimeMillis(); 330 331 ojbChangeReferenceSetting(ObjectA.class, "refAA", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 332 ojbChangeReferenceSetting(ObjectAA.class, "refAAA", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 333 ojbChangeReferenceSetting(ObjectAAA.class, "refAAAA", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 334 ojbChangeReferenceSetting(ObjectAAAA.class, "refA", true, ObjectReferenceDescriptor.CASCADE_NONE, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 335 336 ObjectA a = new ObjectA(name + "_ObjectA"); 337 ObjectAA aa = new ObjectAA(name + "_ObjectAA"); 338 ObjectAAA aaa = new ObjectAAA(name + "_ObjectAAA"); 339 ObjectAAAA aaaa = new ObjectAAAA(name + "_ObjectAAAA"); 340 a.setRefAA(aa); 342 aa.setRefAAA(aaa); 343 aaa.setRefAAAA(aaaa); 344 345 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 346 tx.begin(); 347 database.makePersistent(a); 348 tx.commit(); 349 350 tx.begin(); 351 OQLQuery query = odmg.newOQLQuery(); 352 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 353 query.bind(name + "%"); 354 Collection result = (Collection ) query.execute(); 355 assertEquals(1, result.size()); 356 357 query = odmg.newOQLQuery(); 358 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 359 query.bind(name + "%"); 360 result = (Collection ) query.execute(); 361 assertEquals(1, result.size()); 362 363 query = odmg.newOQLQuery(); 364 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 365 query.bind(name + "%"); 366 result = (Collection ) query.execute(); 367 assertEquals(1, result.size()); 368 369 query = odmg.newOQLQuery(); 370 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 371 query.bind(name + "%"); 372 result = (Collection ) query.execute(); 373 assertEquals(1, result.size()); 374 tx.commit(); 375 376 tx.begin(); 377 database.deletePersistent(a); 378 tx.commit(); 379 380 tx.begin(); 381 query = odmg.newOQLQuery(); 382 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 383 query.bind(name + "%"); 384 result = (Collection ) query.execute(); 385 assertEquals(0, result.size()); 386 387 query = odmg.newOQLQuery(); 388 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 389 query.bind(name + "%"); 390 result = (Collection ) query.execute(); 391 assertEquals(0, result.size()); 392 393 query = odmg.newOQLQuery(); 394 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 395 query.bind(name + "%"); 396 result = (Collection ) query.execute(); 397 assertEquals(0, result.size()); 398 399 query = odmg.newOQLQuery(); 400 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 401 query.bind(name + "%"); 402 result = (Collection ) query.execute(); 403 assertEquals(0, result.size()); 404 tx.commit(); 405 } 406 407 410 public void testBidirectionalWithConstraint_1a() throws Exception  411 { 412 String name = "testBidirectionalWithConstraint_1a_" + System.currentTimeMillis(); 413 414 Shop s1 = new Shop(name + "_1"); 415 ShopDetail sd = new ShopDetail(name + "_1"); 416 s1.setDetail(sd); 417 sd.setShop(s1); 418 419 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 420 tx.begin(); 421 database.makePersistent(s1); 422 tx.commit(); 423 424 tx.begin(); 425 database.deletePersistent(s1); 426 tx.commit(); 427 } 428 429 432 public void testBidirectionalWithConstraint_1b() throws Exception  433 { 434 String name = "testBidirectionalWithConstraint_1b_" + System.currentTimeMillis(); 435 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 436 tx.begin(); 437 438 Shop s1 = new Shop(name + "_1"); 439 database.makePersistent(s1); 442 tx.flush(); 444 ShopDetail sd = new ShopDetail(name + "_1"); 445 s1.setDetail(sd); 447 sd.setShop(s1); 448 tx.commit(); 453 454 tx.begin(); 455 database.deletePersistent(s1); 459 tx.flush(); 460 database.deletePersistent(sd); 461 tx.commit(); 462 } 463 464 467 public void testBidirectionalWithConstraint_1c() throws Exception  468 { 469 String name = "testBidirectionalWithConstraint_1c_" + System.currentTimeMillis(); 470 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 471 472 Shop s1 = new Shop(name + "_1"); 473 ShopDetail sd = new ShopDetail(name + "_1"); 474 s1.setDetail(sd); 475 sd.setShop(s1); 476 477 tx.setImplicitLocking(false); 479 tx.begin(); 483 database.makePersistent(sd); 487 database.makePersistent(s1); 488 tx.commit(); 489 490 tx.begin(); 492 database.deletePersistent(s1); 495 database.deletePersistent(sd); 496 tx.commit(); 497 } 498 499 505 public void testBidirectionalWithConstraint_1d_PB() throws Exception  506 { 507 ojbChangeReferenceSetting(Shop.class, "detail", true, ObjectReferenceDescriptor.CASCADE_OBJECT, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 508 ojbChangeReferenceSetting(ShopDetail.class, "shop", true, ObjectReferenceDescriptor.CASCADE_OBJECT, ObjectReferenceDescriptor.CASCADE_OBJECT, false); 509 String name = "testBidirectionalWithConstraint_1a_" + System.currentTimeMillis(); 510 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 511 tx.begin(); 512 513 Shop s1 = new Shop(name + "_1"); 514 ShopDetail sd = new ShopDetail(name + "_1"); 515 s1.setDetail(sd); 516 sd.setShop(s1); 517 518 tx.getBroker().beginTransaction(); 520 tx.getBroker().store(s1); 521 tx.commit(); 522 523 524 tx.begin(); 525 tx.getBroker().beginTransaction(); 527 tx.getBroker().delete(s1); 530 tx.commit(); 531 } 532 533 538 public void testBidirectionalWithConstraint_1e() throws Exception  539 { 540 String name = "testBidirectionalWithConstraint_1e_" + System.currentTimeMillis(); 541 ObjectReferenceDescriptor ord = null; 542 543 try 544 { 545 CircularTest.Shop s1 = new CircularTest.Shop(name + "_1"); 546 CircularTest.ShopDetail sd = new CircularTest.ShopDetail(name + "_1"); 547 s1.setDetail(sd); 548 sd.setShop(s1); 549 550 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 551 tx.begin(); 552 ClassDescriptor cld = tx.getBroker().getClassDescriptor(CircularTest.Shop.class); 555 ord = cld.getObjectReferenceDescriptorByName("detail"); 556 ord.setConstraint(true); 559 database.makePersistent(sd); 562 tx.commit(); 565 566 tx.begin(); 567 tx.setCascadingDelete(CircularTest.ShopDetail.class, true); 570 database.deletePersistent(sd); 571 tx.commit(); 574 } 575 finally 576 { 577 if(ord != null) ord.setConstraint(false); 579 } 580 } 581 582 585 public void testCircularOneToOne_1a() throws Exception  586 { 587 String name = "testCircularOneToOne_1a_" + System.currentTimeMillis(); 588 589 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 590 tx.begin(); 591 592 ObjectA a = new ObjectA(name + "_ObjectA"); 593 ObjectAA aa = new ObjectAA(name + "_ObjectAA"); 594 ObjectAAA aaa = new ObjectAAA(name + "_ObjectAAA"); 595 a.setRefAA(aa); 597 aa.setRefAAA(aaa); 598 aaa.setRefA(a); 599 database.makePersistent(a); 600 tx.commit(); 601 602 tx.begin(); 603 database.deletePersistent(a); 604 tx.commit(); 605 606 tx.begin(); 607 OQLQuery query = odmg.newOQLQuery(); 608 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 609 query.bind(name + "%"); 610 Collection result = (Collection ) query.execute(); 611 assertEquals(0, result.size()); 612 613 query = odmg.newOQLQuery(); 614 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 615 query.bind(name + "%"); 616 result = (Collection ) query.execute(); 617 assertEquals(1, result.size()); 618 619 query = odmg.newOQLQuery(); 620 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 621 query.bind(name + "%"); 622 result = (Collection ) query.execute(); 623 assertEquals(1, result.size()); 624 625 query = odmg.newOQLQuery(); 626 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 627 query.bind(name + "%"); 628 result = (Collection ) query.execute(); 629 assertEquals(0, result.size()); 630 tx.commit(); 631 } 632 633 636 public void testCircularOneToOne_1b() throws Exception  637 { 638 String name = "testCircularOneToOne_1b_" + System.currentTimeMillis(); 639 640 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 641 tx.begin(); 642 643 ObjectA a = new ObjectA(name + "_ObjectA"); 644 ObjectAA aa = new ObjectAA(name + "_ObjectAA"); 645 ObjectAAA aaa = new ObjectAAA(name + "_ObjectAAA"); 646 ObjectAAAA aaaa = new ObjectAAAA(name + "_ObjectAAAA"); 647 a.setRefAA(aa); 649 aa.setRefAAA(aaa); 650 aaa.setRefAAAA(aaaa); 651 aaaa.setRefA(a); 652 database.makePersistent(a); 653 tx.commit(); 654 655 tx.begin(); 656 OQLQuery query = odmg.newOQLQuery(); 657 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 658 query.bind(name + "%"); 659 Collection result = (Collection ) query.execute(); 660 assertEquals(1, result.size()); 661 662 query = odmg.newOQLQuery(); 663 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 664 query.bind(name + "%"); 665 result = (Collection ) query.execute(); 666 assertEquals(1, result.size()); 667 668 query = odmg.newOQLQuery(); 669 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 670 query.bind(name + "%"); 671 result = (Collection ) query.execute(); 672 assertEquals(1, result.size()); 673 674 query = odmg.newOQLQuery(); 675 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 676 query.bind(name + "%"); 677 result = (Collection ) query.execute(); 678 assertEquals(1, result.size()); 679 tx.commit(); 680 681 tx.begin(); 682 database.deletePersistent(a); 683 tx.commit(); 684 685 tx.begin(); 686 query = odmg.newOQLQuery(); 687 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 688 query.bind(name + "%"); 689 result = (Collection ) query.execute(); 690 assertEquals(0, result.size()); 691 692 query = odmg.newOQLQuery(); 693 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 694 query.bind(name + "%"); 695 result = (Collection ) query.execute(); 696 assertEquals(1, result.size()); 697 698 query = odmg.newOQLQuery(); 699 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 700 query.bind(name + "%"); 701 result = (Collection ) query.execute(); 702 assertEquals(1, result.size()); 703 704 query = odmg.newOQLQuery(); 705 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 706 query.bind(name + "%"); 707 result = (Collection ) query.execute(); 708 assertEquals(1, result.size()); 709 tx.commit(); 710 } 711 712 716 public void testCircularOneToOne_1c() throws Exception  717 { 718 String name = "testCircularOneToOne_1d_" + System.currentTimeMillis(); 719 720 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 721 tx.begin(); 722 723 ObjectA a = new ObjectA(name + "_ObjectA"); 724 ObjectAA aa = new ObjectAA(name + "_ObjectAA"); 725 ObjectAAA aaa = new ObjectAAA(name + "_ObjectAAA"); 726 ObjectAAAA aaaa = new ObjectAAAA(name + "_ObjectAAAA"); 727 a.setRefAA(aa); 729 aa.setRefAAA(aaa); 730 aaa.setRefAAAA(aaaa); 731 aaaa.setRefA(a); 732 733 737 tx.setOrdering(false); 738 tx.setImplicitLocking(false); 739 740 database.makePersistent(aaaa); 741 database.makePersistent(aaa); 742 database.makePersistent(aa); 743 database.makePersistent(a); 744 tx.commit(); 745 746 tx.begin(); 747 OQLQuery query = odmg.newOQLQuery(); 748 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 749 query.bind(name + "%"); 750 Collection result = (Collection ) query.execute(); 751 assertEquals(1, result.size()); 752 753 query = odmg.newOQLQuery(); 754 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 755 query.bind(name + "%"); 756 result = (Collection ) query.execute(); 757 assertEquals(1, result.size()); 758 759 query = odmg.newOQLQuery(); 760 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 761 query.bind(name + "%"); 762 result = (Collection ) query.execute(); 763 assertEquals(1, result.size()); 764 765 query = odmg.newOQLQuery(); 766 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 767 query.bind(name + "%"); 768 result = (Collection ) query.execute(); 769 assertEquals(1, result.size()); 770 tx.commit(); 771 772 tx.begin(); 773 777 database.deletePersistent(a); 778 database.deletePersistent(aa); 779 database.deletePersistent(aaa); 780 database.deletePersistent(aaaa); 781 tx.commit(); 782 783 tx.begin(); 784 query = odmg.newOQLQuery(); 785 query.create("select objects from " + ObjectA.class.getName() + " where name like $1"); 786 query.bind(name + "%"); 787 result = (Collection ) query.execute(); 788 assertEquals(0, result.size()); 789 790 query = odmg.newOQLQuery(); 791 query.create("select objects from " + ObjectAA.class.getName() + " where name like $1"); 792 query.bind(name + "%"); 793 result = (Collection ) query.execute(); 794 assertEquals(0, result.size()); 795 796 query = odmg.newOQLQuery(); 797 query.create("select objects from " + ObjectAAA.class.getName() + " where name like $1"); 798 query.bind(name + "%"); 799 result = (Collection ) query.execute(); 800 assertEquals(0, result.size()); 801 802 query = odmg.newOQLQuery(); 803 query.create("select objects from " + ObjectAAAA.class.getName() + " where name like $1"); 804 query.bind(name + "%"); 805 result = (Collection ) query.execute(); 806 assertEquals(0, result.size()); 807 tx.commit(); 808 } 809 810 813 public void testCircularOneToOne_1dd() throws Exception  814 { 815 String name = "testCircularOneToOne_1dd_" + System.currentTimeMillis(); 816 817 TransactionExt tx = (TransactionExt) odmg.newTransaction(); 818 tx.begin(); 819 820 ObjectA a = new ObjectA(name + "_ObjectA"); 821 ObjectAA aa = new ObjectAA(name + "_ObjectAA"); 822 ObjectAAA aaa = new ObjectAAA(name + "_ObjectAAA"); 823 ObjectAAAA aaaa = new ObjectAAAA(name + "_ObjectAAAA"); 824 a.setRefAA(aa); 826 aa.setRefAAA(aaa); 827 aaa.setRefAAAA(aaaa); 828 aaaa.setRefA(a); 829 830 833 tx.setOrdering(false); 834 tx.setImplicitLocking(false); 835 836 database.makePersistent(aaaa); 837 database.makePersistent(aaa); 838 database.makePersistent(aa); 839 database.makePersistent(a); 840 tx.commit(); 841 842 tx.begin(); 843 846 database.deletePersistent(a); 847 database.deletePersistent(aa); 848 database.deletePersistent(aaa); 849 database.deletePersistent(aaaa); 850 tx.commit(); 851 852 &nbs
|