Skip to content
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

importing many-to-many relationships feature #130

Open
vitalz opened this issue Jun 19, 2017 · 2 comments
Open

importing many-to-many relationships feature #130

vitalz opened this issue Jun 19, 2017 · 2 comments

Comments

@vitalz
Copy link

vitalz commented Jun 19, 2017

Cayenne does not generate (associative) entity classes for many-to-many database tables when junction table just keeps only foreign keys: for instance, product and right has relationship defined by table record {product_id, right_id}. LinkMove has to provide ability to import/remove relationships in a some way like:

    LmTask task = lmRuntime.getTaskService()
                            .createOrUpdateRelationship(Product.class, Right.class)
			.sourceExtractor("product_group_has_right")
			.matchBy(Product.class, Right.class)
			.task();

Issue is per my talk to @rzen.

@atomashpolskiy
Copy link
Member

I like the idea, but the proposed implementation does not make much sense. Product and Right may have multiple relationships.

A junction table is a database entity, and the most natural solution would be to provide the API to synchronize database entities. Most parts should be already there, e.g.

  • source extractor can map to database columns (i.e. in your case will contain mappings for db:product_id and db:right_id)
  • rows can be matched by PK via matchById() (might need some tweaks if it relies on the ObjectId internally)

@andrus
Copy link
Contributor

andrus commented Jun 20, 2017

+1 on DbEntity sync. I had a similar idea when we discussed it with @rzen .

@atomashpolskiy : let's discuss offline some time after July 3 (or sooner over video chat if you need to).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants