Diego,
Thanks again. This really helped and I appreciate you walking through
it with me. I think I was too wrapped up in database performance and
the queries that were being executed. I forgot that domain
cleanliness should also play a factor in my decision.
One more question:
If I wanted to get a list of a user's friends whose name began with
the letter "A", would you recommend creating a separate query to fetch
that information using HQL/Criteria/SQL or would you iterate over the
Friends collection and do it in memory? My initial impression would
be to use a query for situations like this, and the object graph for
things like adding/removing a user's friends.
Kevin
On Nov 25, 9:11 am, Diego Mijelshon <
di...@mijelshon.com.ar> wrote:
> Well, the ORM works by creating a representation of what's in the database,
> which allows you to work with persistence ignorance on the object model, and
> that includes adding and removing elements from a collection, which is then
> mapped to inserting and deleting records from a DB table.
>
> Now, there *IS* an alternative to what I proposed that might be more aligned
> with your original idea.
> Instead of loading the collection, you could try to get the record from the
> Friends table which represents the relationship. However, in order to do
> that, you have to change your domain model and usage to adjust to that
> particular use case, which is what you should avoid.
>
> There are always tradeoffs with ORMs, but the benefits largely are way
> bigger than the costs.
>
> Diego
>
> > <
nhusers%2Bunsu...@googlegroups.com<
nhusers%252Buns...@googlegroups.com>>