-
Notifications
You must be signed in to change notification settings - Fork 245
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
Accessing a many to one object #906
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Question How can I query the categories of a product? I am trying to match the categories with the passed in the query.
Situation
I want to be able to search for categories of products.
I have two tables for this:
interface Product { @Bindable @ManyToOne ProductCategoryEntity getCategory(); }
and
interface ProductCategory { @OneToMany(mappedBy = "category", cascade = {CascadeAction.SAVE}) List<ProductEntity> getProducts(); }
I want to access the categories of products
This is my approach
Selection<ReactiveResult<ProductEntity>> productsSelection = mDataStore.select(ProductEntity.class); productsSelection.where(ProductEntity.OWNER.eq(merchantEntity)); productsSelection.where(ProductEntity.NAME.like(query)).or(ProductEntity.CATEGORY.like(query); productsSelection.where(ProductEntity.DELETED.notEqual(true));
This does not match the name of the category as I stated here
productsSelection.where(ProductEntity.NAME.like(query)).or(ProductEntity.CATEGORY.like(query);
How can I go about getting the categories of a product as this is returning null
What is the right approach to getting data from many to one relationships?
The text was updated successfully, but these errors were encountered: