Patent ID: 7054858

Claim:
A method for retrieving target objects stored in a relational database to which an object model is mapped, the method comprising steps of: generating a retrieval query to read target objects for a collection of source objects, the collection of source objects having many-to-many relationships with the target objects, the collection of source objects and target objects being respectively stored in one or more source tables and target tables in the database, and the many-to-many relationship being defined in the database by using an intermediate join table of the source tables and the target tables, wherein the retrieval query is generated by: obtaining a source expression tree relating to the collection of the source objects; building a target expression tree defined by the many-to-many mapping including a join between the target tables and the join table; combining the source expression tree and the target expression tree to produce a combined expression tree; and generating the retrieval query based on the combined expression tree; selecting join table information from the many-to-many join table relating to the collection of source objects and the target objects to enable matching of the target objects and the source objects using the join table information; and retrieving the matched target objects by executing the retrieval query on the database; wherein retrieving the matched target objects involves automatically generating the query, and wherein the matched target objects include only many-to-many target objects, whereby the matched target objects can be retrieved without requiring a user to provide an explicit list of the matched target objects.