On 25/03/11 10:25 PM, Israel Ben Guilherme Fonseca wrote:
I'm using it for a stand alone APP, no rails.

I didn't know about this repository function. Does it MUST be used for
every database conversation in an standalone app?
only if you want the identity map, otherwise no.


2011/3/24 Xavier (DBIYF) <[email protected]
<mailto:[email protected]>>



    On 24/03/11 11:13 PM, Israel Ben Guilherme Fonseca wrote:

        Hello,

        Maybe what I'm asking don't make sense to the Datamapper
        context, but
        here it goes:

        In SQLAlchemy and Hibernate there's the concept of session context,
        where an IdentityMap have references to the entities that are
        attached
        in the the current session context. In these frameworks you have to
        eventually make a session.clear() or session.close(). You
        normally use a
        clear() in Hibernate to make batch inserts.

        Anyway, my question is: is there any similar concepts in
        datamapper? I
        didnt find anything in the docs. If i had a DAO like this:

        class PessoaDAO
             def insert(pessoa)
                 pessoa.save
             end
        end

        I could call this 1 million times without the fear of filling my
        system
        memory?(Without a clear this would happen in hibernate, and without
        autocommit i think that too would happen in SQLAlchemy.

    The identity map is only used when you are explicitly inside a
    repository block:

    DataMapper.repository(:default) do
      # Identity map used here
    end
    # Cleared by here, and not used anymore

    If you called 1 million inserts inside the block, then yes your
    memory would fill up.

    If you are using datamapper with rails and insert the identity map
    middleware, you get an identity map for the scope of one request.

    Hope that helps,
    Xavier

    --
    You received this message because you are subscribed to the Google
    Groups "DataMapper" group.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:datamapper%[email protected]>.
    For more options, visit this group at
    http://groups.google.com/group/datamapper?hl=en.


--
You received this message because you are subscribed to the Google
Groups "DataMapper" 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/datamapper?hl=en.

--
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en.

Reply via email to