Am Freitag, 3. Mai 2013 13:44:20 UTC+2 schrieb Arnon Marcus:
>
>
> Sorry, but what should do .list() ? 
>> it is a query? it is pre-fetched or cached? 
>>
>
> The whole point of having an ORM, is for you to not have to worry about 
> the answer to that question - it's gonna do the optimal thing it can, based 
> on the circumstances in which it is called.
>
>
Here's the problem. In a perfect world you don't have to worry about what's 
going on behind the scenes. In a real application you need to know what 
exactly the ORM is doing, otherwise you'll run into problems sooner or 
later.

I had to work with an ORM (Hibernate) for many years. The ORM is very 
convenient but the "magic" which is going on in the background will cause 
you trouble (at least performance-wise). I'm really happy to use web2py and 
the DAL for my own project, I always know what exactly is going on and I 
never encountered a strange bug where I could not figure out what's going 
on. Not so with the ORM where I lost many hours debugging unexcepted 
behavior.

In my opinion it does not make sense to define how references are fetched 
on an object level (at least that's how it is done in Hibernate, don't know 
about SQLA). E.g. when I query a City object I can't say in advance if I 
always want to access the Country reference as well. In Hibernate single 
references have eager loading so they are always fetched. That's bad 
because when you don't need the reference there is unnecessary data fetched 
(and of course this is recursive, e.g. if Country has a single reference 
itself this will also be loaded). With lazy loading you often run into the 
problem that the session or transaction is not active anymore and the 
references cannot be accessed (just google for "Lazy Loading Exception"). 
Therefor we often loaded all those references when the object is queried to 
avoid running into a lazy loading exception later on - which is of course 
also not very good for performance. With the DAL I say exactly what I need 
(joining the tables I really need for my use case) and when, that's so much 
better and easier than depending on some ORM magic.

For me all the added internal complexity of an ORM is not worth the effort. 
The complexity is just shifted to a different layer. Maybe the videos and 
presentations of SQLA look nice and promising but you'll only find out 
about the disadvantages (which are not mentioned in the videos of course) 
once you develop a real world application.

Alex
 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to