1

I have a table with more than one Many2Many-Association to other tables. The names of the tables and columns are a little confusing, so i have to use the @Many2Many-Annotation. But i can´t use this annotation twice?!

What is the recommended way to handle this?

CSan
  • 954
  • 1
  • 10
  • 25

1 Answers1

0

Sorry for changing the answer. I did not think at first, but ActiveJDBC can support this requirement out of the box, no need to implement new code.

Many2Many annotation is placed on one end of a relationship. This means that if you have TABLE1, TABLE2 and TABLE3 such that TABLE1 has many to many with TABLE2 and it has many to many to TABLE2, you can put Many2Many annotations on models representing TABLE2 and TABLE3, while TABLE1 does not have to have any annotations.

In this example, I omitted the join tables for clarity.

You can take a look at this: http://javalite.io/many_to_many_associations#overriding-associations for explanation of the "one sidedness" of ActiveJDBC annotations.

Hope this helps,

cheers

ipolevoy
  • 5,432
  • 2
  • 31
  • 46
  • typo: read this: "and it has many to many to TABLE2" like this: "and it has many to many to TABLE3", sorry – ipolevoy Aug 03 '11 at 21:59
  • ok, but if i place the @ManyToMany-Annotation on the other side of the assosiation, there is an error, which tells me that the association is not defined in my model and shows me all available associations of the model(which is the association i have placed in Table1) – CSan Aug 05 '11 at 10:15
  • sorry just saw this comment, for faster response, please post questions to: https://groups.google.com/forum/#!forum/activejdbc-group. This sounds pretty strange given that you specify association in annotations. Please post a question on the ActiveJDBC Google Groups with snippet of code so that we can model your situation internally – ipolevoy Aug 13 '11 at 20:26