4 Replies Latest reply on Sep 4, 2002 1:21 PM by kellyschrock

    M:M Relationship in JBoss (CMP)

    kellyschrock

      Is this known to work? I have a couple of entities that I've defined as having a many-to-many relation between them. I'm using a mapping table, and when I run a piece of test code to demonstrate the relationship, JBoss locks up and won't do anything at all until I kill/restart it. Anyone else having (or had) this problem?

      Thanks...

        • 1. Re: M:M Relationship in JBoss (CMP)
          dsundstrom

          Works for me. There are a lot of tests (that run every day) that test many to many relationships. Get the Quick Start Guide; it has a many to many example (I think).

          • 2. Re: M:M Relationship in JBoss (CMP)
            kellyschrock

            After a little more digging, I found that I can get my test(s) to run (read as "not lock up") only if there are no records in the mapping table. In other words, I can put records in table A, and records in table B, and it works as expected. But if I put records in table A_B (the mapping table), it locks up. For the purposes of my test, I'm putting the records in the mapping table manually, while JBoss is not running. In addition, I can use a query tool to verify that I can get records out of the database in the expected manner. Incidentally, I'm using SQL Server 2k.

            In addition, having tried to run the test and failing, JBoss spontaneously spits out a stack trace mentioning something about a MethodLock failing (I'm sorry, I don't have the text of the error message in front of me). I don't know whether there's a connection here.

            The problem seems to be centered around the relationships I'm defining in ejb-jar.xml. If I specify it as a 1:n relationship (in either direction), it works fine, with or without records in the mapping table. It only locks up when I define the relationship as n:n.

            • 3. Re: M:M Relationship in JBoss (CMP)
              dsundstrom

              Can you get a thread dumb when it locks up? Where is is blocking?

              Are you using method locks or the normal pessimistic locking?

              Can you post a bug report with a test case?

              • 4. Re: M:M Relationship in JBoss (CMP)
                kellyschrock


                Oops, my bad... I have a piece of code that creates and returns Value Object-type copies of entity beans; This code recursively dives into an object and copies all of its nested attributes (including sub-objects and collections), unless it's instructed not to in the deployment descriptor. In this case, the parent of the two classes who had the n:n relation was being "deep-copied", and since each of the two items under the parent contained references to the other, you can imagine the rest. I had forgotten to specify the appropriate configuration, but now it's working great. I appreciate the help.