[
https://issues.apache.org/jira/browse/TORQUE-343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15395360#comment-15395360
]
Thomas Vandahl commented on TORQUE-343:
---------------------------------------
About the complex query case:
Say, I have an application with a complex data model. I want to display a list
of data coming from different tables. So I create a query with lots of select
columns, several joins and a complex where-condition. This can be a pain to
handle.
So I apply the Peer/Mapper/OM-class pattern to this type of query by creating
an OM-class containing the select columns of my query, a mapper to map the
results to this object and a peerImpl to run the query. (An instance of
BasePeerImpl configured accordingly, will do, too).
This way, you can use the complex query like any other Peer/OM-class
combination. You may look at it as a kind of "dynamic view". The only caveat is
that a static peer class would be needed to avoid creating the peerImpl
instances. You /can/ do this, of course but I consider the registry method more
elegant.
> Implement a central registry for peerImpls like the registry for managers
> -------------------------------------------------------------------------
>
> Key: TORQUE-343
> URL: https://issues.apache.org/jira/browse/TORQUE-343
> Project: Torque
> Issue Type: Improvement
> Components: Runtime, Templates
> Affects Versions: 4.0
> Reporter: Thomas Vandahl
> Assignee: Thomas Vandahl
> Fix For: 4.1
>
>
> I'd like to suggest a central registry for peerImpl-objects which can be
> queried by the Persistent class it is responsible for. This would allow
> reusing and extending the peer objects dynamically as well as giving them
> some kind of life-cycle.
> The main method would be similar to this:
> {code:java}
> public <T> BasePeerImpl<T> getPeerFor(Class<T> persistentClass)
> {
> return peerRegistry.get(persistentClass);
> }
> {code}
> I would also like to suggest moving the buildCriteria(obj) method to the
> RecordMapper or the TableMap class. This will further reduce the amount of
> code that needs to be generated.
> If the idea is received well, I'll come up with a proposal.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]