开发者

ActiveJDBC More than one Many2Many-association

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 开发者_Python百科this?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜