-
Notifications
You must be signed in to change notification settings - Fork 694
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
set many-to-many relation using a DAO #347
Comments
Try this:
There are no add/remove/other collections functions at the moment. I guess it's possible to extend InnerTableLink class with other operators like plus/plusAssign/etc. I created the issue for this (#348) P.S.: Will wait for wiki improvements from you! :D |
Thanks for the quick reply.
Here's the corresponding stack trace:
I had to split the creation and setting of the relation into two transactions:
I'm not sure if this behavior is intended. |
This is surely a bug, but it can't be fixed in a simple way. The problem is that at the moment Exposed trying to insert a reference to not-initialized entity. It should be replaced with scheduled insert, but that's not so easy:D |
Figured out how to make it work in a single transaction when using
Just useful for |
I have another queston for this statement:
It realy work for save relatonship via manyTomany. But it will delete other relationship!!! Why? |
@RDCynthia , because you don't add relation but re-set whole relations. |
@Tapac how to add new item to the collection without re-setting? I didn't find any example on how to do that. SizedIterable is read-only. One way I see: sql, but I'd like to do that with dao :) |
I also want to know this . |
By resetting as stated by @Tapac, can confirm that Exposed handles unique records of related entities in the join table so you can just update related entities by reassigning a |
I searched for an answer online but wasn't able to find one.
I created my tables according to this issue.
I want to store albums and artists. They should be related by a many-to-many relation.
These are my tables:
While filling the database i couldn't figure out how to set the many-to-many relation. I tried it this way but it didn't work:
Additionally i took a look at methods of
Album.artists
and couldn't find anything likeadd
.Am i supposed to create a class
AlbumArtist
and set the relation withAlbumArtist.new
?I'll gladly update the wiki with examples for this scenario as soon as i know how to do it.
The text was updated successfully, but these errors were encountered: