> Why not just write queries (either Criteria or HQL) to get the > information you want?
This is a possibility though I am trying to find another solution if there is one. Because I do not know the types until runtime and the types do not know about each other until runtime either, I would have to use reflection to search through all the properties on the types and generate queries that would find references to each Type of object in the entire database.... possible, but not straightforward. Though, if you think this is pretty easy - I'd love to know how you would do it, I'm looking for the simplest/felxible solution. > In your first example, if you query for a particular person, you'll > get their Mum, Dad and BestFriend because they are related via the > BelongsTo property. In your second example, if you have a Pet object > loaded from the database, it will already have a reference to it's > owner via the Owner property. In the first example, it is supposed to fetch it's Mum/dad/Bestfriend (all easy if you have the original record) but it is ALSO supposed to return it's children (any other people who reference it in their records) and all of it's pets! So it is not so simple as inspecting the record. To better describe the situation, Imagine I have written an application that stores Person records, and their social linkages. But I have also added the ability for plugins to the App to specify different types of objects - i.e. Pets. Now, I want to be able to develop an editor for this DB such that I can edit the contents of a Person (easy), but on the side of the editor I wish to see a list of all the objects in the DB that reference the one I am currently editing (the subject of this thread). In reality that isn't the application btw Hopefully that is a bit clearer? I experimented with giving the Person class a "HasManyToAny" property with Inverse=true, in the hope that that collection would get populated with Pets whenever they reference that Person... but no joy... At this stage it is looking like I will need to use reflection to generate queries for each object type... i.e. look through all the ActiveRecord types and find all the properties with "Person" type, then do a query that hunts down any references to a specific person... Josh -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
