-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @OneToMany annotation as alternative to @BelongsTo #664
Comments
Enable logging and see how the framework discovers @BelongsTo. It creates two associations: has many and belongs to at the same time. Not sure why you think there is a cyclic dependency. We were able to use this to even create tree structures of one to many dependencies of the same type. |
Children.java:
Parent.java:
Tools like Sonar or IntelliJ IDEA ("Analyze Cyclic Dependencies") will tell you that there is a cyclic dependency between package moduleA and moduleB. If these packages were in different modules of a multi-module project, the code wouldn't even compile. If there were a annotation |
@cschabl when you mention models, are you talking about Java 9, or you mean Maven modules? |
small note: I suggest a singular form to name models (Child rather than Children), since there is one instance created per row. |
I think I understand your issue. You split your models across Maven modules and the reactor cannot figure out what module to compile first, right? Generally, the best practice is to have all your models in the same module, since they are the DB access layer. We usually have a module |
Hi Igor, in the "multi-module project" example, I meant a Maven module. But in this conversation I generally take the perspective of software architecture/design modelling. In this context I should rather use the term "component" instead of "module". As we decided to lay out the Java package structure along our component model instead of the architectural layers, we don't have a Java package or project module Removing the BelongsTo annotation from our child model class results in a "not associated" exception by ActiveJDBC. That is, our DB schema given by our DB architect doesn't conform to ActiveJDBC conventions here. So a @OneToMany wouldn't force me to introduce a cyclic dependency between components or to follow a certain package or project module layout. |
@cschabl this is a relatively easy task to do. If you have some time, take a look at how this works. Specifically there are Association objects created during the registration phase in the Registry. If you can contribute, I will guide and help you. If not, I will get to it later sometime, 2 -3 weeks time frame. |
I guess, the starting point would be |
@cschabl this is correct. The
.. but nothing bad should happen. Additionally, the new annotation should be called |
@ipolevoy can you take a look on my branch enhancement #664. If the changes are ok, I will adapt the other StatementProvider classes and submit a pull request. |
@cschabl looks great, add support to other DBs, and submit a PL |
…r other supported databases
@cschabl seems your SQL scripts are missing CREATE statements? |
#664 Add @OneToMany annotation as alternative to @BelongsTo (create-table statements for other DBs)
@cschabl PR merged, lets see it it fixes the builds. |
…tatements #664: create table statements for teams and players for other DBs.
Fixed in 2.2 |
👍 |
This is great. |
There should be a @OneToMany annotation for associating parent models with child models for loading child models with getAll() from the parent model, because adding a @BelongsTo to the child model introduces a cyclic dependency between parent and child.
The latter is ok if both parent and child are in the same package. But if they are in different logical modules, it could be objectionable.
The text was updated successfully, but these errors were encountered: