I have two entity objects, USER and GROUP. GROUP contains a ManyToMany relationship to USER, but that relationship is not bidirectional.
My problem is that I need to find out all of the USERs that are members of a list of GROUPs. If I could reverse the relationship so that the USER contained the relationship to GROUP, I could do this easily, but I can't seem to figure out how to write the JPQL to go the other way.
Can someone out there point me in the right direction?
Thanks
The following seems to work:
select distinct u from User u, Group grp where grp in (?1) and u member of grp.users
Related
How to configure User entity, to have OneToOne() relation with Profile entity with a extra condition. ie
if the User type is TYPE_A, then the User entity should have relation with ProfileA
or
if the User type is TYPE_B, then the User entity should have a relation with ProfileB
and so on...
Is it possible to achieve something like this?
I need to do a many to many relationship in my first Access 2013 web app.
I have a Parents table and a Students table. Each student can have two parents and each parent can have more than one student in the school.
Thinking like a seasoned Access desktop developer I took the usual route of creating a parents_students table to link the other two then hit a wall. How do I make the view show the relationship?
I found this topic: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ccda03e3-a57b-4128-be72-f469c8ec30af/access-2013-web-app-handling-many-to-many-relationships?forum=accessdev
When I tried it, it is not doing what I want, or I am doing something wrong.
Seems like a very fundamental thing to be able to do.
Got an answer over at the MSDN forums. Link Here
Create a Parents_Students table with three fields
ID: AutoNumber
Student: Lookup the name field in the student table
Parent: lookup the name field in the parent table
To the Students View, add a SubView and add a tab called Parents. In the Data parameters set the Data Source to the Parents_Students table and the related field to Student.
Repeat the same procedure on the Parents View but use parent as the Related Field.
I'm working with a database that I can't change, and I'm working with EF database-first...
I've got some tables with a many-to-many relation to a 'shared' table.
The relation based on the keys is many-to-many, but it's actually zero-or-one-to-many relation made unique by a fixed value in the shared table.
Example:
Table1; field:code, ...
Table2; field:code, ...
SharedTable; key1:code, key2:tablename, ...
If I use the EF designer to model this, I can only use the Table1:code to SharedTable:key1 for the assiociation, resulting in a many-to-many relation which is not allowed.
Is there any way to 'model' these associations to include a fixed value for SharedTable:key2, or force many-to-many relations to be allowed, so I could add the 'where key2=tablename' and ' manually for example?
Of course I could always resort to dropping the associations and joining manually...
So I've got a Client entity that needs a relationship to a PhoneNumber entity to allow multiple phone numbers. And I've got an Employee entity that also needs a relationship to a PhoneNumber entity to allow multiple phone numbers. Should I create two separate PhoneNumber entities or can I somehow use the same entity for both?
I would create a parent entity called Person for your Client and Employee entities. The Person entity would have a relationship to the PhoneNumber entity.
Inherited entities have the same attributes and relationships as their parent entity. Of course you can add attributes and relationships to the "child"-entities as well. I omitted that in the screenshot.
Something like this:
you can configure the parent entity in the core data inspector in the right side pane.
Lets say I have a many-to-many relationship:
Group table
User table
group_user table which is a many to many table
Given the group name I would like to find all the users that belong to this group.
How can I do this with subsonic 3.0?
IQueryable<group_user> groupUser= group_user.All();
Is it possible from groupUser to get all users who belong to a specific group say group 1?
Is there any other way
Use a linq statment.
something like (very rough):
var users = from gu in group_user.All()
join g on group.All()
join u on user.All()
where g.Name = "My Group"
select u;
If you provide me with your schema I'll be able to knockup a working example.