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

Exception - unable to set mappedBy child object #66

Closed
munish-usit opened this issue Dec 10, 2020 · 3 comments
Closed

Exception - unable to set mappedBy child object #66

munish-usit opened this issue Dec 10, 2020 · 3 comments

Comments

@munish-usit
Copy link

I am using below structure

class ProfileEntity{
.......
@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST)
@JoinProperty(name="emailNotificationsId")
private List emailNotifications;
}

public class EmailNotificationsEntity {

@Id
private Integer emailNotificationsId;
@Field(name="email_notifications_name")
private String name;

@ManyToOne(mappedBy = "emailNotifications")
private List<ProfileEntity> profiles;

}

For this structure i am getting below error while fetching ProfileEntity data

io.github.kaiso.relmongo.exception.RelMongoProcessingException: unable to set mappedBy child object Can not set java.util.List field com.test.core.profile.entity.EmailNotificationsEntity.profiles to com.test.core.profile.entity.ProfileEntity

@kaiso
Copy link
Owner

kaiso commented Dec 10, 2020

Hello @munish-usit thank you for using RelMongo, your issue is that @ManyToOne can only be used on an attribute of type object and not collection so in your case you should have :
@ManyToOne(mappedBy = "emailNotifications") private ProfileEntity profile;

@munish-usit
Copy link
Author

Hello @kaiso ,
Thanks for your solution. Your solution has solved the run time error, but unfortunately, in my use case I have to use List profiles because its a many to many relationship.
One profile can have many email notifications.
One email notification can be subscribed by many profile.

Do you have any plan to support List in many to many relationship ?

Thanks,
Munish

@kaiso
Copy link
Owner

kaiso commented Dec 17, 2020

Hello @munish-usit Unfortunately I have no plan for that for now, I have studied the feature and the outcome was that it is very complex.

@kaiso kaiso closed this as completed Jan 24, 2021
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

2 participants