1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class CollectionTagIndirectionTableAttributeTests extends OjbTestBase 24 { 25 public CollectionTagIndirectionTableAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testIndirectionTable1() 33 { 34 addClass( 35 "test.A", 36 "package test;\n"+ 37 "/** @ojb.class */\n" + 38 "public class A {\n"+ 39 " /** @ojb.field primarykey=\"true\" */\n"+ 40 " private int id;\n"+ 41 " /** @ojb.collection foreignkey=\"AID\"\n"+ 42 " * indirection-table=\"A_B\"\n"+ 43 " */\n"+ 44 " private B[] bs;\n"+ 45 "}"); 46 addClass( 47 "test.B", 48 "package test;\n"+ 49 "/** @ojb.class\n"+ 50 " * @ojb.field name=\"id\"\n"+ 51 " * jdbc-type=\"INTEGER\"\n"+ 52 " * primarykey=\"true\"\n"+ 53 " */\n"+ 54 "public class B {\n"+ 55 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 56 " * foreignkey=\"BID\"\n"+ 57 " * indirection-table=\"A_B\"\n"+ 58 " */\n"+ 59 " private org.apache.ojb.odmg.collections.DListImpl as;\n"+ 60 "}\n"); 61 62 assertEqualsOjbDescriptorFile( 63 "<class-descriptor\n"+ 64 " class=\"test.A\"\n"+ 65 " table=\"A\"\n"+ 66 ">\n"+ 67 " <field-descriptor\n"+ 68 " name=\"id\"\n"+ 69 " column=\"id\"\n"+ 70 " jdbc-type=\"INTEGER\"\n"+ 71 " primarykey=\"true\"\n"+ 72 " >\n"+ 73 " </field-descriptor>\n"+ 74 " <collection-descriptor\n"+ 75 " name=\"bs\"\n"+ 76 " element-class-ref=\"test.B\"\n"+ 77 " indirection-table=\"A_B\"\n"+ 78 " >\n"+ 79 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 80 " <fk-pointing-to-element-class column=\"BID\"/>\n"+ 81 " </collection-descriptor>\n"+ 82 "</class-descriptor>\n"+ 83 "<class-descriptor\n"+ 84 " class=\"test.B\"\n"+ 85 " table=\"B\"\n"+ 86 ">\n"+ 87 " <field-descriptor\n"+ 88 " name=\"id\"\n"+ 89 " column=\"id\"\n"+ 90 " jdbc-type=\"INTEGER\"\n"+ 91 " primarykey=\"true\"\n"+ 92 " access=\"anonymous\"\n"+ 93 " >\n"+ 94 " </field-descriptor>\n"+ 95 " <collection-descriptor\n"+ 96 " name=\"as\"\n"+ 97 " collection-class=\"org.apache.ojb.odmg.collections.DListImpl\"\n"+ 98 " element-class-ref=\"test.A\"\n"+ 99 " indirection-table=\"A_B\"\n"+ 100 " >\n"+ 101 " <fk-pointing-to-this-class column=\"BID\"/>\n"+ 102 " <fk-pointing-to-element-class column=\"AID\"/>\n"+ 103 " </collection-descriptor>\n"+ 104 "</class-descriptor>", 105 runOjbXDoclet(OJB_DEST_FILE)); 106 assertEqualsTorqueSchemaFile( 107 "<database name=\"ojbtest\">\n"+ 108 " <table name=\"A\">\n"+ 109 " <column name=\"id\"\n"+ 110 " javaName=\"id\"\n"+ 111 " type=\"INTEGER\"\n"+ 112 " primaryKey=\"true\"\n"+ 113 " required=\"true\"\n"+ 114 " />\n"+ 115 " </table>\n"+ 116 " <table name=\"A_B\">\n"+ 117 " <column name=\"AID\"\n"+ 118 " type=\"INTEGER\"\n"+ 119 " />\n"+ 120 " <column name=\"BID\"\n"+ 121 " type=\"INTEGER\"\n"+ 122 " />\n"+ 123 " <foreign-key foreignTable=\"A\">\n"+ 124 " <reference local=\"AID\" foreign=\"id\"/>\n"+ 125 " </foreign-key>\n"+ 126 " <foreign-key foreignTable=\"B\">\n"+ 127 " <reference local=\"BID\" foreign=\"id\"/>\n"+ 128 " </foreign-key>\n"+ 129 " </table>\n"+ 130 " <table name=\"B\">\n"+ 131 " <column name=\"id\"\n"+ 132 " javaName=\"id\"\n"+ 133 " type=\"INTEGER\"\n"+ 134 " primaryKey=\"true\"\n"+ 135 " required=\"true\"\n"+ 136 " />\n"+ 137 " </table>\n"+ 138 "</database>", 139 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 140 } 141 142 public void testIndirectionTable2() 144 { 145 addClass( 146 "test.A", 147 "package test;\n"+ 148 "/** @ojb.class */\n" + 149 "public class A {\n"+ 150 " /** @ojb.field primarykey=\"true\" */\n"+ 151 " private org.apache.ojb.broker.util.GUID id;\n"+ 152 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 153 " * foreignkey=\"AID\"\n"+ 154 " * indirection-table=\"A_B\"\n"+ 155 " */\n"+ 156 " private java.util.List bs;\n"+ 157 "}"); 158 addClass( 159 "test.B", 160 "package test;\n"+ 161 "/** @ojb.class */\n"+ 162 "public class B {\n"+ 163 " /** @ojb.field primarykey=\"true\" */\n"+ 164 " private java.util.Date id;\n"+ 165 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 166 " * foreignkey=\"BID\"\n"+ 167 " * indirection-table=\"A_B\"\n"+ 168 " */\n"+ 169 " private "+TestCollectionClass.class.getName()+" as;\n"+ 170 "}\n"); 171 172 assertEqualsOjbDescriptorFile( 173 "<class-descriptor\n"+ 174 " class=\"test.A\"\n"+ 175 " table=\"A\"\n"+ 176 ">\n"+ 177 " <field-descriptor\n"+ 178 " name=\"id\"\n"+ 179 " column=\"id\"\n"+ 180 " jdbc-type=\"VARCHAR\"\n"+ 181 " primarykey=\"true\"\n"+ 182 " conversion=\"org.apache.ojb.broker.accesslayer.conversions.GUID2StringFieldConversion\"\n"+ 183 " length=\"254\"\n"+ 184 " >\n"+ 185 " </field-descriptor>\n"+ 186 " <collection-descriptor\n"+ 187 " name=\"bs\"\n"+ 188 " element-class-ref=\"test.B\"\n"+ 189 " indirection-table=\"A_B\"\n"+ 190 " >\n"+ 191 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 192 " <fk-pointing-to-element-class column=\"BID\"/>\n"+ 193 " </collection-descriptor>\n"+ 194 "</class-descriptor>\n"+ 195 "<class-descriptor\n"+ 196 " class=\"test.B\"\n"+ 197 " table=\"B\"\n"+ 198 ">\n"+ 199 " <field-descriptor\n"+ 200 " name=\"id\"\n"+ 201 " column=\"id\"\n"+ 202 " jdbc-type=\"DATE\"\n"+ 203 " primarykey=\"true\"\n"+ 204 " >\n"+ 205 " </field-descriptor>\n"+ 206 " <collection-descriptor\n"+ 207 " name=\"as\"\n"+ 208 " collection-class=\""+TestCollectionClass.class.getName()+"\"\n"+ 209 " element-class-ref=\"test.A\"\n"+ 210 " indirection-table=\"A_B\"\n"+ 211 " >\n"+ 212 " <fk-pointing-to-this-class column=\"BID\"/>\n"+ 213 " <fk-pointing-to-element-class column=\"AID\"/>\n"+ 214 " </collection-descriptor>\n"+ 215 "</class-descriptor>", 216 runOjbXDoclet(OJB_DEST_FILE)); 217 assertEqualsTorqueSchemaFile( 218 "<database name=\"ojbtest\">\n"+ 219 " <table name=\"A\">\n"+ 220 " <column name=\"id\"\n"+ 221 " javaName=\"id\"\n"+ 222 " type=\"VARCHAR\"\n"+ 223 " primaryKey=\"true\"\n"+ 224 " required=\"true\"\n"+ 225 " size=\"254\"\n"+ 226 " />\n"+ 227 " </table>\n"+ 228 " <table name=\"A_B\">\n"+ 229 " <column name=\"AID\"\n"+ 230 " type=\"VARCHAR\"\n"+ 231 " size=\"254\"\n"+ 232 " />\n"+ 233 " <column name=\"BID\"\n"+ 234 " type=\"DATE\"\n"+ 235 " />\n"+ 236 " <foreign-key foreignTable=\"A\">\n"+ 237 " <reference local=\"AID\" foreign=\"id\"/>\n"+ 238 " </foreign-key>\n"+ 239 " <foreign-key foreignTable=\"B\">\n"+ 240 " <reference local=\"BID\" foreign=\"id\"/>\n"+ 241 " </foreign-key>\n"+ 242 " </table>\n"+ 243 " <table name=\"B\">\n"+ 244 " <column name=\"id\"\n"+ 245 " javaName=\"id\"\n"+ 246 " type=\"DATE\"\n"+ 247 " primaryKey=\"true\"\n"+ 248 " required=\"true\"\n"+ 249 " />\n"+ 250 " </table>\n"+ 251 "</database>", 252 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 253 } 254 255 public void testIndirectionTable3() 257 { 258 addClass( 259 "test.A", 260 "package test;\n"+ 261 "/** @ojb.class */\n" + 262 "public class A {\n"+ 263 " /** @ojb.field primarykey=\"true\" */\n"+ 264 " private int id;\n"+ 265 " /** @ojb.field */\n"+ 266 " private int bid;\n"+ 267 " /** @ojb.collection foreignkey=\"AID\"\n"+ 268 " * indirection-table=\"A_B\"\n"+ 269 " */\n"+ 270 " private B[] bs;\n"+ 271 "}"); 272 addClass( 273 "test.B", 274 "package test;\n"+ 275 "/** @ojb.class */\n"+ 276 "public class B {\n"+ 277 " /** @ojb.field primarykey=\"true\" */\n"+ 278 " private int id;\n"+ 279 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 280 " * foreignkey=\"bid\"\n"+ 281 " */\n"+ 282 " private java.util.List as;\n"+ 283 "}\n"); 284 285 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 286 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 287 } 288 289 public void testIndirectionTable4() 291 { 292 addClass( 293 "test.A", 294 "package test;\n"+ 295 "/** @ojb.class */\n" + 296 "public class A {\n"+ 297 " /** @ojb.field primarykey=\"true\" */\n"+ 298 " private int id;\n"+ 299 " /** @ojb.collection foreignkey=\"AID\"\n"+ 300 " * indirection-table=\"A_B\"\n"+ 301 " */\n"+ 302 " private B[] bs;\n"+ 303 "}"); 304 addClass( 305 "test.B", 306 "package test;\n"+ 307 "/** @ojb.class */\n"+ 308 "public class B {\n"+ 309 " /** @ojb.field primarykey=\"true\" */\n"+ 310 " private int id;\n"+ 311 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 312 " * foreignkey=\"BID\"\n"+ 313 " * indirection-table=\"B_A\"\n"+ 314 " */\n"+ 315 " private java.util.List as;\n"+ 316 "}\n"); 317 318 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 319 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 320 } 321 322 public void testIndirectionTable5() 324 { 325 addClass( 326 "test.A", 327 "package test;\n"+ 328 "/** @ojb.class */\n" + 329 "public class A {\n"+ 330 " /** @ojb.field primarykey=\"true\" */\n"+ 331 " private int id;\n"+ 332 " /** @ojb.collection foreignkey=\"AID\"\n"+ 333 " * indirection-table=\"A_B\"\n"+ 334 " */\n"+ 335 " private B[] bs;\n"+ 336 "}"); 337 addClass( 338 "test.B", 339 "package test;\n"+ 340 "/** @ojb.class */\n"+ 341 "public class B {\n"+ 342 " /** @ojb.field primarykey=\"true\" */\n"+ 343 " private int id;\n"+ 344 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 345 " * foreignkey=\"BID\"\n"+ 346 " * remote-foreignkey=\"AID\"\n"+ 347 " * indirection-table=\"A_B\"\n"+ 348 " */\n"+ 349 " private java.util.List as;\n"+ 350 "}\n"); 351 352 assertEqualsOjbDescriptorFile( 353 "<class-descriptor\n"+ 354 " class=\"test.A\"\n"+ 355 " table=\"A\"\n"+ 356 ">\n"+ 357 " <field-descriptor\n"+ 358 " name=\"id\"\n"+ 359 " column=\"id\"\n"+ 360 " jdbc-type=\"INTEGER\"\n"+ 361 " primarykey=\"true\"\n"+ 362 " >\n"+ 363 " </field-descriptor>\n"+ 364 " <collection-descriptor\n"+ 365 " name=\"bs\"\n"+ 366 " element-class-ref=\"test.B\"\n"+ 367 " indirection-table=\"A_B\"\n"+ 368 " >\n"+ 369 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 370 " <fk-pointing-to-element-class column=\"BID\"/>\n"+ 371 " </collection-descriptor>\n"+ 372 "</class-descriptor>\n"+ 373 "<class-descriptor\n"+ 374 " class=\"test.B\"\n"+ 375 " table=\"B\"\n"+ 376 ">\n"+ 377 " <field-descriptor\n"+ 378 " name=\"id\"\n"+ 379 " column=\"id\"\n"+ 380 " jdbc-type=\"INTEGER\"\n"+ 381 " primarykey=\"true\"\n"+ 382 " >\n"+ 383 " </field-descriptor>\n"+ 384 " <collection-descriptor\n"+ 385 " name=\"as\"\n"+ 386 " element-class-ref=\"test.A\"\n"+ 387 " indirection-table=\"A_B\"\n"+ 388 " >\n"+ 389 " <fk-pointing-to-this-class column=\"BID\"/>\n"+ 390 " <fk-pointing-to-element-class column=\"AID\"/>\n"+ 391 " </collection-descriptor>\n"+ 392 "</class-descriptor>", 393 runOjbXDoclet(OJB_DEST_FILE)); 394 assertEqualsTorqueSchemaFile( 395 "<database name=\"ojbtest\">\n"+ 396 " <table name=\"A\">\n"+ 397 " <column name=\"id\"\n"+ 398 " javaName=\"id\"\n"+ 399 " type=\"INTEGER\"\n"+ 400 " primaryKey=\"true\"\n"+ 401 " required=\"true\"\n"+ 402 " />\n"+ 403 " </table>\n"+ 404 " <table name=\"A_B\">\n"+ 405 " <column name=\"AID\"\n"+ 406 " type=\"INTEGER\"\n"+ 407 " />\n"+ 408 " <column name=\"BID\"\n"+ 409 " type=\"INTEGER\"\n"+ 410 " />\n"+ 411 " <foreign-key foreignTable=\"A\">\n"+ 412 " <reference local=\"AID\" foreign=\"id\"/>\n"+ 413 " </foreign-key>\n"+ 414 " <foreign-key foreignTable=\"B\">\n"+ 415 " <reference local=\"BID\" foreign=\"id\"/>\n"+ 416 " </foreign-key>\n"+ 417 " </table>\n"+ 418 " <table name=\"B\">\n"+ 419 " <column name=\"id\"\n"+ 420 " javaName=\"id\"\n"+ 421 " type=\"INTEGER\"\n"+ 422 " primaryKey=\"true\"\n"+ 423 " required=\"true\"\n"+ 424 " />\n"+ 425 " </table>\n"+ 426 "</database>", 427 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 428 } 429 430 public void testIndirectionTable6() 432 { 433 addClass( 434 "test.A", 435 "package test;\n"+ 436 "/** @ojb.class */\n" + 437 "public class A {\n"+ 438 " /** @ojb.field primarykey=\"true\" */\n"+ 439 " private int id;\n"+ 440 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 441 " * foreignkey=\"AID\"\n"+ 442 " * indirection-table=\"A_B\"\n"+ 443 " */\n"+ 444 " private java.util.List bs;\n"+ 445 "}"); 446 addClass( 447 "test.B", 448 "package test;\n"+ 449 "/** @ojb.class */\n"+ 450 "public class B {\n"+ 451 " /** @ojb.field primarykey=\"true\" */\n"+ 452 " private int id;\n"+ 453 "}\n"); 454 455 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 456 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 457 } 458 459 public void testIndirectionTable7() 461 { 462 addClass( 463 "test.A", 464 "package test;\n"+ 465 "/** @ojb.class */\n" + 466 "public class A {\n"+ 467 " /** @ojb.field primarykey=\"true\" */\n"+ 468 " private int id;\n"+ 469 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 470 " * foreignkey=\"AID\"\n"+ 471 " * remote-foreignkey=\"\"\n"+ 472 " * indirection-table=\"A_B\"\n"+ 473 " */\n"+ 474 " private java.util.List bs;\n"+ 475 "}"); 476 addClass( 477 "test.B", 478 "package test;\n"+ 479 "/** @ojb.class */\n"+ 480 "public class B {\n"+ 481 " /** @ojb.field primarykey=\"true\" */\n"+ 482 " private int id;\n"+ 483 "}\n"); 484 485 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 486 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 487 } 488 489 public void testIndirectionTable8() 491 { 492 addClass( 493 "test.A", 494 "package test;\n"+ 495 "/** @ojb.class */\n" + 496 "public class A {\n"+ 497 " /** @ojb.field primarykey=\"true\" */\n"+ 498 " private int id;\n"+ 499 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 500 " * foreignkey=\"AID\"\n"+ 501 " * remote-foreignkey=\"BID\"\n"+ 502 " * indirection-table=\"A_B\"\n"+ 503 " */\n"+ 504 " private java.util.List bs;\n"+ 505 "}"); 506 addClass( 507 "test.B", 508 "package test;\n"+ 509 "/** @ojb.class */\n"+ 510 "public class B {\n"+ 511 " /** @ojb.field primarykey=\"true\" */\n"+ 512 " private String id;\n"+ 513 "}\n"); 514 515 assertEqualsOjbDescriptorFile( 516 "<class-descriptor\n"+ 517 " class=\"test.A\"\n"+ 518 " table=\"A\"\n"+ 519 ">\n"+ 520 " <field-descriptor\n"+ 521 " name=\"id\"\n"+ 522 " column=\"id\"\n"+ 523 " jdbc-type=\"INTEGER\"\n"+ 524 " primarykey=\"true\"\n"+ 525 " >\n"+ 526 " </field-descriptor>\n"+ 527 " <collection-descriptor\n"+ 528 " name=\"bs\"\n"+ 529 " element-class-ref=\"test.B\"\n"+ 530 " indirection-table=\"A_B\"\n"+ 531 " >\n"+ 532 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 533 " <fk-pointing-to-element-class column=\"BID\"/>\n"+ 534 " </collection-descriptor>\n"+ 535 "</class-descriptor>\n"+ 536 "<class-descriptor\n"+ 537 " class=\"test.B\"\n"+ 538 " table=\"B\"\n"+ 539 ">\n"+ 540 " <field-descriptor\n"+ 541 " name=\"id\"\n"+ 542 " column=\"id\"\n"+ 543 " jdbc-type=\"VARCHAR\"\n"+ 544 " primarykey=\"true\"\n"+ 545 " length=\"254\"\n"+ 546 " >\n"+ 547 " </field-descriptor>\n"+ 548 "</class-descriptor>", 549 runOjbXDoclet(OJB_DEST_FILE)); 550 assertEqualsTorqueSchemaFile( 551 "<database name=\"ojbtest\">\n"+ 552 " <table name=\"A\">\n"+ 553 " <column name=\"id\"\n"+ 554 " javaName=\"id\"\n"+ 555 " type=\"INTEGER\"\n"+ 556 " primaryKey=\"true\"\n"+ 557 " required=\"true\"\n"+ 558 " />\n"+ 559 " </table>\n"+ 560 " <table name=\"A_B\">\n"+ 561 " <column name=\"AID\"\n"+ 562 " type=\"INTEGER\"\n"+ 563 " />\n"+ 564 " <column name=\"BID\"\n"+ 565 " type=\"VARCHAR\"\n"+ 566 " size=\"254\"\n"+ 567 " />\n"+ 568 " <foreign-key foreignTable=\"A\">\n"+ 569 " <reference local=\"AID\" foreign=\"id\"/>\n"+ 570 " </foreign-key>\n"+ 571 " <foreign-key foreignTable=\"B\">\n"+ 572 " <reference local=\"BID\" foreign=\"id\"/>\n"+ 573 " </foreign-key>\n"+ 574 " </table>\n"+ 575 " <table name=\"B\">\n"+ 576 " <column name=\"id\"\n"+ 577 " javaName=\"id\"\n"+ 578 " type=\"VARCHAR\"\n"+ 579 " primaryKey=\"true\"\n"+ 580 " required=\"true\"\n"+ 581 " size=\"254\"\n"+ 582 " />\n"+ 583 " </table>\n"+ 584 "</database>", 585 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 586 } 587 588 public void testIndirectionTable9() 590 { 591 addClass( 592 "test.A", 593 "package test;\n"+ 594 "/** @ojb.class */\n" + 595 "public class A {\n"+ 596 " /** @ojb.field primarykey=\"true\" */\n"+ 597 " private int id1;\n"+ 598 " /** @ojb.field primarykey=\"true\" */\n"+ 599 " private String id2;\n"+ 600 " /** @ojb.field primarykey=\"true\" */\n"+ 601 " private int id3;\n"+ 602 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 603 " * foreignkey=\"AID1,AID2,AID3\"\n"+ 604 " * remote-foreignkey=\"BID1,BID2\"\n"+ 605 " * indirection-table=\"A_B\"\n"+ 606 " */\n"+ 607 " private java.util.List bs;\n"+ 608 "}"); 609 addClass( 610 "test.B", 611 "package test;\n"+ 612 "/** @ojb.class */\n"+ 613 "public class B {\n"+ 614 " /** @ojb.field primarykey=\"true\" */\n"+ 615 " private String id1;\n"+ 616 " /** @ojb.field primarykey=\"true\" */\n"+ 617 " private int id2;\n"+ 618 "}\n"); 619 620 assertEqualsOjbDescriptorFile( 621 "<class-descriptor\n"+ 622 " class=\"test.A\"\n"+ 623 " table=\"A\"\n"+ 624 ">\n"+ 625 " <field-descriptor\n"+ 626 " name=\"id1\"\n"+ 627 " column=\"id1\"\n"+ 628 " jdbc-type=\"INTEGER\"\n"+ 629 " primarykey=\"true\"\n"+ 630 " >\n"+ 631 " </field-descriptor>\n"+ 632 " <field-descriptor\n"+ 633 " name=\"id2\"\n"+ 634 " column=\"id2\"\n"+ 635 " jdbc-type=\"VARCHAR\"\n"+ 636 " primarykey=\"true\"\n"+ 637 " length=\"254\"\n"+ 638 " >\n"+ 639 " </field-descriptor>\n"+ 640 " <field-descriptor\n"+ 641 " name=\"id3\"\n"+ 642 " column=\"id3\"\n"+ 643 " jdbc-type=\"INTEGER\"\n"+ 644 " primarykey=\"true\"\n"+ 645 " >\n"+ 646 " </field-descriptor>\n"+ 647 " <collection-descriptor\n"+ 648 " name=\"bs\"\n"+ 649 " element-class-ref=\"test.B\"\n"+ 650 " indirection-table=\"A_B\"\n"+ 651 " >\n"+ 652 " <fk-pointing-to-this-class column=\"AID1\"/>\n"+ 653 " <fk-pointing-to-this-class column=\"AID2\"/>\n"+ 654 " <fk-pointing-to-this-class column=\"AID3\"/>\n"+ 655 " <fk-pointing-to-element-class column=\"BID1\"/>\n"+ 656 " <fk-pointing-to-element-class column=\"BID2\"/>\n"+ 657 " </collection-descriptor>\n"+ 658 "</class-descriptor>\n"+ 659 "<class-descriptor\n"+ 660 " class=\"test.B\"\n"+ 661 " table=\"B\"\n"+ 662 ">\n"+ 663 " <field-descriptor\n"+ 664 " name=\"id1\"\n"+ 665 " column=\"id1\"\n"+ 666 " jdbc-type=\"VARCHAR\"\n"+ 667 " primarykey=\"true\"\n"+ 668 " length=\"254\"\n"+ 669 " >\n"+ 670 " </field-descriptor>\n"+ 671 " <field-descriptor\n"+ 672 " name=\"id2\"\n"+ 673 " column=\"id2\"\n"+ 674 " jdbc-type=\"INTEGER\"\n"+ 675 " primarykey=\"true\"\n"+ 676 " >\n"+ 677 " </field-descriptor>\n"+ 678 "</class-descriptor>", 679 runOjbXDoclet(OJB_DEST_FILE)); 680 assertEqualsTorqueSchemaFile( 681 "<database name=\"ojbtest\">\n"+ 682 " <table name=\"A\">\n"+ 683 " <column name=\"id1\"\n"+ 684 " javaName=\"id1\"\n"+ 685 " type=\"INTEGER\"\n"+ 686 " primaryKey=\"true\"\n"+ 687 " required=\"true\"\n"+ 688 " />\n"+ 689 " <column name=\"id2\"\n"+ 690 " javaName=\"id2\"\n"+ 691 " type=\"VARCHAR\"\n"+ 692 " primaryKey=\"true\"\n"+ 693 " required=\"true\"\n"+ 694 " size=\"254\"\n"+ 695 " />\n"+ 696 " <column name=\"id3\"\n"+ 697 " javaName=\"id3\"\n"+ 698 " type=\"INTEGER\"\n"+ 699 " primaryKey=\"true\"\n"+ 700 " required=\"true\"\n"+ 701 " />\n"+ 702 " </table>\n"+ 703 " <table name=\"A_B\">\n"+ 704 " <column name=\"AID1\"\n"+ 705 " type=\"INTEGER\"\n"+ 706 " />\n"+ 707 " <column name=\"AID2\"\n"+ 708 " type=\"VARCHAR\"\n"+ 709 " size=\"254\"\n"+ 710 " />\n"+ 711 " <column name=\"AID3\"\n"+ 712 " type=\"INTEGER\"\n"+ 713 " />\n"+ 714 " <column name=\"BID1\"\n"+ 715 " type=\"VARCHAR\"\n"+ 716 " size=\"254\"\n"+ 717 " />\n"+ 718 " <column name=\"BID2\"\n"+ 719 " type=\"INTEGER\"\n"+ 720 " />\n"+ 721 " <foreign-key foreignTable=\"A\">\n"+ 722 " <reference local=\"AID1\" foreign=\"id1\"/>\n"+ 723 " <reference local=\"AID2\" foreign=\"id2\"/>\n"+ 724 " <reference local=\"AID3\" foreign=\"id3\"/>\n"+ 725 " </foreign-key>\n"+ 726 " <foreign-key foreignTable=\"B\">\n"+ 727 " <reference local=\"BID1\" foreign=\"id1\"/>\n"+ 728 " <reference local=\"BID2\" foreign=\"id2\"/>\n"+ 729 " </foreign-key>\n"+ 730 " </table>\n"+ 731 " <table name=\"B\">\n"+ 732 " <column name=\"id1\"\n"+ 733 " javaName=\"id1\"\n"+ 734 " type=\"VARCHAR\"\n"+ 735 " primaryKey=\"true\"\n"+ 736 " required=\"true\"\n"+ 737 " size=\"254\"\n"+ 738 " />\n"+ 739 " <column name=\"id2\"\n"+ 740 " javaName=\"id2\"\n"+ 741 " type=\"INTEGER\"\n"+ 742 " primaryKey=\"true\"\n"+ 743 " required=\"true\"\n"+ 744 " />\n"+ 745 " </table>\n"+ 746 "</database>", 747 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 748 } 749 750 public void testIndirectionTable10() 752 { 753 addClass( 754 "test.A", 755 "package test;\n"+ 756 "/** @ojb.class */\n" + 757 "public class A {\n"+ 758 " /** @ojb.field primarykey=\"true\" */\n"+ 759 " private int id;\n"+ 760 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 761 " * foreignkey=\"AID\"\n"+ 762 " * indirection-table=\"A_B\"\n"+ 763 " */\n"+ 764 " private java.util.List bs;\n"+ 765 "}"); 766 addClass( 767 "test.B", 768 "package test;\n"+ 769 "/** @ojb.class */\n"+ 770 "public class B {\n"+ 771 " /** @ojb.field primarykey=\"true\" */\n"+ 772 " private String id;\n"+ 773 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 774 " * foreignkey=\"BID\"\n"+ 775 " * indirection-table=\"A_B\"\n"+ 776 " */\n"+ 777 " private java.util.List as;\n"+ 778 "}\n"); 779 addClass( 780 "test.C", 781 "package test;\n"+ 782 "/** @ojb.class */\n"+ 783 "public class C extends B {}\n"); 784 785 assertEqualsOjbDescriptorFile( 786 "<class-descriptor\n"+ 787 " class=\"test.A\"\n"+ 788 " table=\"A\"\n"+ 789 ">\n"+ 790 " <field-descriptor\n"+ 791 " name=\"id\"\n"+ 792 " column=\"id\"\n"+ 793 " jdbc-type=\"INTEGER\"\n"+ 794 " primarykey=\"true\"\n"+ 795 " >\n"+ 796 " </field-descriptor>\n"+ 797 " <collection-descriptor\n"+ 798 " name=\"bs\"\n"+ 799 " element-class-ref=\"test.B\"\n"+ 800 " indirection-table=\"A_B\"\n"+ 801 " >\n"+ 802 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 803 " <fk-pointing-to-element-class column=\"BID\"/>\n"+ 804 " </collection-descriptor>\n"+ 805 "</class-descriptor>\n"+ 806 "<class-descriptor\n"+ 807 " class=\"test.B\"\n"+ 808 " table=\"B\"\n"+ 809 ">\n"+ 810 " <extent-class class-ref=\"test.C\"/>\n"+ 811 " <field-descriptor\n"+ 812 " name=\"id\"\n"+ 813 " column=\"id\"\n"+ 814 " jdbc-type=\"VARCHAR\"\n"+ 815 " primarykey=\"true\"\n"+ 816 " length=\"254\"\n"+ 817 " >\n"+ 818 " </field-descriptor>\n"+ 819 " <collection-descriptor\n"+ 820 " name=\"as\"\n"+ 821 " element-class-ref=\"test.A\"\n"+ 822 " indirection-table=\"A_B\"\n"+ 823 " >\n"+ 824 " <fk-pointing-to-this-class column=\"BID\"/>\n"+ 825 " <fk-pointing-to-element-class column=\"AID\"/>\n"+ 826 " </collection-descriptor>\n"+ 827 "</class-descriptor>\n"+ 828 "<class-descriptor\n"+ 829 " class=\"test.C\"\n"+ 830 " table=\"C\"\n"+ 831 ">\n"+ 832 " <field-descriptor\n"+ 833 " name=\"id\"\n"+ 834 " column=\"id\"\n"+ 835 " jdbc-type=\"VARCHAR\"\n"+ 836 " primarykey=\"true\"\n"+ 837 " length=\"254\"\n"+ 838 " >\n"+ 839 " </field-descriptor>\n"+ 840 " <collection-descriptor\n"+ 841 " name=\"as\"\n"+ 842 " element-class-ref=\"test.A\"\n"+ 843 " indirection-table=\"A_B\"\n"+ 844 " >\n"+ 845 " <fk-pointing-to-this-class column=\"BID\"/>\n"+ 846 " <fk-pointing-to-element-class column=\"AID\"/>\n"+ 847 " </collection-descriptor>\n"+ 848 "</class-descriptor>", 849 runOjbXDoclet(OJB_DEST_FILE)); 850 assertEqualsTorqueSchemaFile( 851 "<database name=\"ojbtest\">\n"+ 852 " <table name=\"A\">\n"+ 853 " <column name=\"id\"\n"+ 854 " javaName=\"id\"\n"+ 855 " type=\"INTEGER\"\n"+ 856 " primaryKey=\"true\"\n"+ 857 " required=\"true\"\n"+ 858 " />\n"+ 859 " </table>\n"+ 860 " <table name=\"A_B\">\n"+ 861 " <column name=\"AID\"\n"+ 862 " type=\"INTEGER\"\n"+ 863 " />\n"+ 864 " <column name=\"BID\"\n"+ 865 " type=\"VARCHAR\"\n"+ 866 " size=\"254\"\n"+ 867 " />\n"+ 868 " </table>\n"+ 869 " <table name=\"B\">\n"+ 870 " <column name=\"id\"\n"+ 871 " javaName=\"id\"\n"+ 872 " type=\"VARCHAR\"\n"+ 873 " primaryKey=\"true\"\n"+ 874 " required=\"true\"\n"+ 875 " size=\"254\"\n"+ 876 " />\n"+ 877 " </table>\n"+ 878 " <table name=\"C\">\n"+ 879 " <column name=\"id\"\n"+ 880 " javaName=\"id\"\n"+ 881 " type=\"VARCHAR\"\n"+ 882 " primaryKey=\"true\"\n"+ 883 " required=\"true\"\n"+ 884 " size=\"254\"\n"+ 885 " />\n"+ 886 " </table>\n"+ 887 "</database>", 888 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 889 } 890 891 public void testIndirectionTable11() 893 { 894 addClass( 895 "test.A", 896 "package test;\n"+ 897 "/** @ojb.class */\n" + 898 "public class A {\n"+ 899 " /** @ojb.field primarykey=\"true\" */\n"+ 900 " private int id;\n"+ 901 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 902 " * foreignkey=\"CHILD_ID\"\n"+ 903 " * indirection-table=\"A_B\"\n"+ 904 " */\n"+ 905 " private java.util.Collection children;\n"+ 906 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 907 " * foreignkey=\"PARENT_ID\"\n"+ 908 " * indirection-table=\"A_B\"\n"+ 909 " */\n"+ 910 " private java.util.Collection parents;\n"+ 911 "}"); 912 913 assertEqualsOjbDescriptorFile( 914 "<class-descriptor\n"+ 915 " class=\"test.A\"\n"+ 916 " table=\"A\"\n"+ 917 ">\n"+ 918 " <field-descriptor\n"+ 919 " name=\"id\"\n"+ 920 " column=\"id\"\n"+ 921 " jdbc-type=\"INTEGER\"\n"+ 922 " primarykey=\"true\"\n"+ 923 " >\n"+ 924 " </field-descriptor>\n"+ 925 " <collection-descriptor\n"+ 926 " name=\"children\"\n"+ 927 " element-class-ref=\"test.A\"\n"+ 928 " indirection-table=\"A_B\"\n"+ 929 " >\n"+ 930 " <fk-pointing-to-this-class column=\"CHILD_ID\"/>\n"+ 931 " <fk-pointing-to-element-class column=\"PARENT_ID\"/>\n"+ 932 " </collection-descriptor>\n"+ 933 " <collection-descriptor\n"+ 934 " name=\"parents\"\n"+ 935 " element-class-ref=\"test.A\"\n"+ 936 " indirection-table=\"A_B\"\n"+ 937 " >\n"+ 938 " <fk-pointing-to-this-class column=\"PARENT_ID\"/>\n"+ 939 " <fk-pointing-to-element-class column=\"CHILD_ID\"/>\n"+ 940 " </collection-descriptor>\n"+ 941 "</class-descriptor>", 942 runOjbXDoclet(OJB_DEST_FILE)); 943 assertEqualsTorqueSchemaFile( 944 "<database name=\"ojbtest\">\n"+ 945 " <table name=\"A\">\n"+ 946 " <column name=\"id\"\n"+ 947 " javaName=\"id\"\n"+ 948 " type=\"INTEGER\"\n"+ 949 " primaryKey=\"true\"\n"+ 950 " required=\"true\"\n"+ 951 " />\n"+ 952 " </table>\n"+ 953 " <table name=\"A_B\">\n"+ 954 " <column name=\"CHILD_ID\"\n"+ 955 " type=\"INTEGER\"\n"+ 956 " />\n"+ 957 " <column name=\"PARENT_ID\"\n"+ 958 " type=\"INTEGER\"\n"+ 959 " />\n"+ 960 " <foreign-key foreignTable=\"A\">\n"+ 961 " <reference local=\"CHILD_ID\" foreign=\"id\"/>\n"+ 962 " </foreign-key>\n"+ 963 " <foreign-key foreignTable=\"A\">\n"+ 964 " <reference local=\"PARENT_ID\" foreign=\"id\"/>\n"+ 965 " </foreign-key>\n"+ 966 " </table>\n"+ 967 "</database>", 968 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 969 } 970 971 public void testIndirectionTable12() 973 { 974 addClass( 975 "test.A", 976 "package test;\n"+ 977 "/** @ojb.class */\n" + 978 "public class A {\n"+ 979 " /** @ojb.field primarykey=\"true\" */\n"+ 980 " private int id;\n"+ 981 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 982 " * foreignkey=\"PARENT_ID\"\n"+ 983 " * remote-foreignkey=\"CHILD_ID\"\n"+ 984 " * indirection-table=\"PARENT_CHILD\"\n"+ 985 " */\n"+ 986 " private java.util.Collection children;\n"+ 987 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 988 " * foreignkey=\"CHILD_ID\"\n"+ 989 " * remote-foreignkey=\"PARENT_ID\"\n"+ 990 " * indirection-table=\"PARENT_CHILD\"\n"+ 991 " */\n"+ 992 " private java.util.Collection parents;\n"+ 993 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 994 " * foreignkey=\"RIGHT_ID\"\n"+ 995 " * remote-foreignkey=\"LEFT_ID\"\n"+ 996 " * indirection-table=\"NEIGHBOURS\"\n"+ 997 " */\n"+ 998 " private java.util.Collection leftNeighbors;\n"+ 999 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 1000 " * foreignkey=\"LEFT_ID\"\n"+ 1001 " * remote-foreignkey=\"RIGHT_ID\"\n"+ 1002 " * indirection-table=\"NEIGHBOURS\"\n"+ 1003 " */\n"+ 1004 " private java.util.Collection rightNeighbors;\n"+ 1005 "}"); 1006 1007 assertEqualsOjbDescriptorFile( 1008 "<class-descriptor\n"+ 1009 " class=\"test.A\"\n"+ 1010 " table=\"A\"\n"+ 1011 ">\n"+ 1012 " <field-descriptor\n"+ 1013 " name=\"id\"\n"+ 1014 " column=\"id\"\n"+ 1015 " jdbc-type=\"INTEGER\"\n"+ 1016 " primarykey=\"true\"\n"+ 1017 " >\n"+ 1018 " </field-descriptor>\n"+ 1019 " <collection-descriptor\n"+ 1020 " name=\"children\"\n"+ 1021 " element-class-ref=\"test.A\"\n"+ 1022 " indirection-table=\"PARENT_CHILD\"\n"+ 1023 " >\n"+ 1024 " <fk-pointing-to-this-class column=\"PARENT_ID\"/>\n"+ 1025 " <fk-pointing-to-element-class column=\"CHILD_ID\"/>\n"+ 1026 " </collection-descriptor>\n"+ 1027 " <collection-descriptor\n"+ 1028 " name=\"parents\"\n"+ 1029 " element-class-ref=\"test.A\"\n"+ 1030 " indirection-table=\"PARENT_CHILD\"\n"+ 1031 " >\n"+ 1032 " <fk-pointing-to-this-class column=\"CHILD_ID\"/>\n"+ 1033 " <fk-pointing-to-element-class column=\"PARENT_ID\"/>\n"+ 1034 " </collection-descriptor>\n"+ 1035 " <collection-descriptor\n"+ 1036 " name=\"leftNeighbors\"\n"+ 1037 " element-class-ref=\"test.A\"\n"+ 1038 " indirection-table=\"NEIGHBOURS\"\n"+ 1039 " >\n"+ 1040 " <fk-pointing-to-this-class column=\"RIGHT_ID\"/>\n"+ 1041 " <fk-pointing-to-element-class column=\"LEFT_ID\"/>\n"+ 1042 " </collection-descriptor>\n"+ 1043 " <collection-descriptor\n"+ 1044 " name=\"rightNeighbors\"\n"+ 1045 " element-class-ref=\"test.A\"\n"+ 1046 " indirection-table=\"NEIGHBOURS\"\n"+ 1047 " >\n"+ 1048 " <fk-pointing-to-this-class column=\"LEFT_ID\"/>\n"+ 1049 " <fk-pointing-to-element-class column=\"RIGHT_ID\"/>\n"+ 1050 " </collection-descriptor>\n"+ 1051 "</class-descriptor>", 1052 runOjbXDoclet(OJB_DEST_FILE)); 1053 assertEqualsTorqueSchemaFile( 1054 "<database name=\"ojbtest\">\n"+ 1055 " <table name=\"A\">\n"+ 1056 " <column name=\"id\"\n"+ 1057 " javaName=\"id\"\n"+ 1058 " type=\"INTEGER\"\n"+ 1059 " primaryKey=\"true\"\n"+ 1060 " required=\"true\"\n"+ 1061 " />\n"+ 1062 " </table>\n"+ 1063 " <table name=\"NEIGHBOURS\">\n"+ 1064 " <column name=\"RIGHT_ID\"\n"+ 1065 " type=\"INTEGER\"\n"+ 1066 " />\n"+ 1067 " <column name=\"LEFT_ID\"\n"+ 1068 " type=\"INTEGER\"\n"+ 1069 " />\n"+ 1070 " <foreign-key foreignTable=\"A\">\n"+ 1071 " <reference local=\"RIGHT_ID\" foreign=\"id\"/>\n"+ 1072 " </foreign-key>\n"+ 1073 " <foreign-key foreignTable=\"A\">\n"+ 1074 " <reference local=\"LEFT_ID\" foreign=\"id\"/>\n"+ 1075 " </foreign-key>\n"+ 1076 " </table>\n"+ 1077 " <table name=\"PARENT_CHILD\">\n"+ 1078 " <column name=\"PARENT_ID\"\n"+ 1079 " type=\"INTEGER\"\n"+ 1080 " />\n"+ 1081 " <column name=\"CHILD_ID\"\n"+ 1082 " type=\"INTEGER\"\n"+ 1083 " />\n"+ 1084 " <foreign-key foreignTable=\"A\">\n"+ 1085 " <reference local=\"PARENT_ID\" foreign=\"id\"/>\n"+ 1086 " </foreign-key>\n"+ 1087 " <foreign-key foreignTable=\"A\">\n"+ 1088 " <reference local=\"CHILD_ID\" foreign=\"id\"/>\n"+ 1089 " </foreign-key>\n"+ 1090 " </table>\n"+ 1091 "</database>", 1092 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 1093 } 1094 1095 public void testIndirectionTable13() 1098 { 1099 addClass( 1100 "test.A", 1101 "package test;\n"+ 1102 "/** @ojb.class */\n" + 1103 "public class A {\n"+ 1104 " /** @ojb.field primarykey=\"true\" */\n"+ 1105 " private org.apache.ojb.broker.util.GUID id;\n"+ 1106 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 1107 " * foreignkey=\"AID\"\n"+ 1108 " * database-foreignkey=\"false\"\n"+ 1109 " * indirection-table=\"A_B\"\n"+ 1110 " */\n"+ 1111 " private java.util.List bs;\n"+ 1112 "}"); 1113 addClass( 1114 "test.B", 1115 "package test;\n"+ 1116 "/** @ojb.class */\n"+ 1117 "public class B {\n"+ 1118 " /** @ojb.field primarykey=\"true\" */\n"+ 1119 " private java.util.Date id;\n"+ 1120 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 1121 " * foreignkey=\"BID\"\n"+ 1122 " * database-foreignkey=\"false\"\n"+ 1123 " * indirection-table=\"A_B\"\n"+ 1124 " */\n"+ 1125 " private "+TestCollectionClass.class.getName()+" as;\n"+ 1126 "}\n"); 1127 1128 assertEqualsOjbDescriptorFile( 1129 "<class-descriptor\n"+ 1130 " class=\"test.A\"\n"+ 1131 " table=\"A\"\n"+ 1132 ">\n"+ 1133 " <field-descriptor\n"+ 1134 " name=\"id\"\n"+ 1135 " column=\"id\"\n"+ 1136 " jdbc-type=\"VARCHAR\"\n"+ 1137 " primarykey=\"true\"\n"+ 1138 " conversion=\"org.apache.ojb.broker.accesslayer.conversions.GUID2StringFieldConversion\"\n"+ 1139 " length=\"254\"\n"+ 1140 " >\n"+ 1141 " </field-descriptor>\n"+ 1142 " <collection-descriptor\n"+ 1143 " name=\"bs\"\n"+ 1144 " element-class-ref=\"test.B\"\n"+ 1145 " indirection-table=\"A_B\"\n"+ 1146 " >\n"+ 1147 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 1148 " <fk-pointing-to-element-class column=\"BID\"/>\n"+ 1149 " </collection-descriptor>\n"+ 1150 "</class-descriptor>\n"+ 1151 "<class-descriptor\n"+ 1152 " class=\"test.B\"\n"+ 1153 " table=\"B\"\n"+ 1154 ">\n"+ 1155 " <field-descriptor\n"+ 1156 " name=\"id\"\n"+ 1157 " column=\"id\"\n"+ 1158 " jdbc-type=\"DATE\"\n"+ 1159 " primarykey=\"true\"\n"+ 1160 " >\n"+ 1161 " </field-descriptor>\n"+ 1162 " <collection-descriptor\n"+ 1163 " name=\"as\"\n"+ 1164 " collection-class=\""+TestCollectionClass.class.getName()+"\"\n"+ 1165 " element-class-ref=\"test.A\"\n"+ 1166 " indirection-table=\"A_B\"\n"+ 1167 " >\n"+ 1168 " <fk-pointing-to-this-class column=\"BID\"/>\n"+ 1169 " <fk-pointing-to-element-class column=\"AID\"/>\n"+ 1170 " </collection-descriptor>\n"+ 1171 "</class-descriptor>", 1172 runOjbXDoclet(OJB_DEST_FILE)); 1173 assertEqualsTorqueSchemaFile( 1174 "<database name=\"ojbtest\">\n"+ 1175 " <table name=\"A\">\n"+ 1176 " <column name=\"id\"\n"+ 1177 " javaName=\"id\"\n"+ 1178 " type=\"VARCHAR\"\n"+ 1179 " primaryKey=\"true\"\n"+ 1180 " required=\"true\"\n"+ 1181 " size=\"254\"\n"+ 1182 " />\n"+ 1183 " </table>\n"+ 1184 " <table name=\"A_B\">\n"+ 1185 " <column name=\"AID\"\n"+ 1186 " type=\"VARCHAR\"\n"+ 1187 " size=\"254\"\n"+ 1188 " />\n"+ 1189 " <column name=\"BID\"\n"+ 1190 " type=\"DATE\"\n"+ 1191 " />\n"+ 1192 " </table>\n"+ 1193 " <table name=\"B\">\n"+ 1194 " <column name=\"id\"\n"+ 1195 " javaName=\"id\"\n"+ 1196 " type=\"DATE\"\n"+ 1197 " primaryKey=\"true\"\n"+ 1198 " required=\"true\"\n"+ 1199 " />\n"+ 1200 " </table>\n"+ 1201 "</database>", 1202 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 1203 } 1204 1205 public void testIndirectionTable14() 1208 { 1209 addClass( 1210 "test.A", 1211 "package test;\n"+ 1212 "/** @ojb.class */\n" + 1213 "public class A {\n"+ 1214 " /** @ojb.field primarykey=\"true\" */\n"+ 1215 " private int id;\n"+ 1216 " /** @ojb.collection foreignkey=\"AID\"\n"+ 1217 " * database-foreignkey=\"false\"\n"+ 1218 " * indirection-table=\"A_B\"\n"+ 1219 " */\n"+ 1220 " private B[] bs;\n"+ 1221 "}"); 1222 addClass( 1223 "test.B", 1224 "package test;\n"+ 1225 "/** @ojb.class\n"+ 1226 " * @ojb.field name=\"id\"\n"+ 1227 " * jdbc-type=\"INTEGER\"\n"+ 1228 " * primarykey=\"true\"\n"+ 1229 " */\n"+ 1230 "public class B {\n"+ 1231 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 1232 " * foreignkey=\"BID\"\n"+ 1233 " * indirection-table=\"A_B\"\n"+ 1234 " */\n"+ 1235 " private org.apache.ojb.odmg.collections.DListImpl as;\n"+ 1236 "}\n"); 1237 1238 assertEqualsOjbDescriptorFile( 1239 "<class-descriptor\n"+ 1240 " class=\"test.A\"\n"+ 1241 " table=\"A\"\n"+ 1242 ">\n"+ 1243 " <field-descriptor\n"+ 1244 " name=\"id\"\n"+ 1245 " column=\"id\"\n"+ 1246 " jdbc-type=\"INTEGER\"\n"+ 1247 " primarykey=\"true\"\n"+ 1248 " >\n"+ 1249 " </field-descriptor>\n"+ 1250 " <collection-descriptor\n"+ 1251 " name=\"bs\"\n"+ 1252 " element-class-ref=\"test.B\"\n"+ 1253 " indirection-table=\"A_B\"\n"+ 1254 " >\n"+ 1255 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 1256 " <fk-pointing-to-element-class column=\"BID\"/>\n"+ 1257 " </collection-descriptor>\n"+ 1258 "</class-descriptor>\n"+ 1259 "<class-descriptor\n"+ 1260 " class=\"test.B\"\n"+ 1261 " table=\"B\"\n"+ 1262 ">\n"+ 1263 " <field-descriptor\n"+ 1264 " name=\"id\"\n"+ 1265 " column=\"id\"\n"+ 1266 " jdbc-type=\"INTEGER\"\n"+ 1267 " primarykey=\"true\"\n"+ 1268 " access=\"anonymous\"\n"+ 1269 " >\n"+ 1270 " </field-descriptor>\n"+ 1271 " <collection-descriptor\n"+ 1272 " name=\"as\"\n"+ 1273 " collection-class=\"org.apache.ojb.odmg.collections.DListImpl\"\n"+ 1274 " element-class-ref=\"test.A\"\n"+ 1275 " indirection-table=\"A_B\"\n"+ 1276 " >\n"+ 1277 " <fk-pointing-to-this-class column=\"BID\"/>\n"+ 1278 " <fk-pointing-to-element-class column=\"AID\"/>\n"+ 1279 " </collection-descriptor>\n"+ 1280 "</class-descriptor>", 1281 runOjbXDoclet(OJB_DEST_FILE)); 1282 assertEqualsTorqueSchemaFile( 1283 "<database name=\"ojbtest\">\n"+ 1284 " <table name=\"A\">\n"+ 1285 " <column name=\"id\"\n"+ 1286 " javaName=\"id\"\n"+ 1287 " type=\"INTEGER\"\n"+ 1288 " primaryKey=\"true\"\n"+ 1289 " required=\"true\"\n"+ 1290 " />\n"+ 1291 " </table>\n"+ 1292 " <table name=\"A_B\">\n"+ 1293 " <column name=\"AID\"\n"+ 1294 " type=\"INTEGER\"\n"+ 1295 " />\n"+ 1296 " <column name=\"BID\"\n"+ 1297 " type=\"INTEGER\"\n"+ 1298 " />\n"+ 1299 " <foreign-key foreignTable=\"B\">\n"+ 1300 " <reference local=\"BID\" foreign=\"id\"/>\n"+ 1301 " </foreign-key>\n"+ 1302 " </table>\n"+ 1303 " <table name=\"B\">\n"+ 1304 " <column name=\"id\"\n"+ 1305 " javaName=\"id\"\n"+ 1306 " type=\"INTEGER\"\n"+ 1307 " primaryKey=\"true\"\n"+ 1308 " required=\"true\"\n"+ 1309 " />\n"+ 1310 " </table>\n"+ 1311 "</database>", 1312 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 1313 } 1314} 1315 | Popular Tags |