You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Evgeny Ryabitskiy (JIRA)" <ji...@apache.org> on 2009/10/01 23:53:23 UTC

[jira] Created: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

SQLTemplate for not-mapping (DataRow) queries
---------------------------------------------

                 Key: CAY-1287
                 URL: https://issues.apache.org/jira/browse/CAY-1287
             Project: Cayenne
          Issue Type: Bug
          Components: Cayenne Core Library
    Affects Versions: 2.0 branch
            Reporter: Evgeny Ryabitskiy
             Fix For: 1.2.5, 2.0.5, 3.0 beta 1, 3.0


I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Ari Maniatis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ari Maniatis updated CAY-1287:
------------------------------

    Issue Type: New Feature  (was: Bug)

> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Ari Maniatis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ari Maniatis updated CAY-1287:
------------------------------

    Fix Version/s:     (was: 3.0 beta 1)
                       (was: 2.0.5)
                       (was: 1.2.5)

> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Evgeny Ryabitskiy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761484#action_12761484 ] 

Evgeny Ryabitskiy commented on CAY-1287:
----------------------------------------

So... why I set it bug and not a new feature....
If you look at Javadoc of SQLTemplate constructor, I can see:

    public SQLTemplate(Class rootClass, String defaultTemplate) {
        setDefaultTemplate(defaultTemplate);
        setRoot(rootClass);
    }

So lets look at setRoot(rootClass) method:

 /**
     * Sets the root of the query
     * 
     * @param value The new root
     * @throws IllegalArgumentException if value is not a String, ObjEntity, DbEntity,
     *             Procedure, DataMap, Class or null. < --- look here!
     */
    public void setRoot(Object value) {...... }

But (!!!) if I pass null it throws exception! Looks like it was expected before to work without mapping for queries....
but implementation not follows it.... 

> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Evgeny Ryabitskiy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761521#action_12761521 ] 

Evgeny Ryabitskiy commented on CAY-1287:
----------------------------------------

Ah yeah... I found way to run SQLTemplate from runtime without objectMapping! wow... It was not easy... really...

But I don't see why we need a DomainMap? We could pass DataNode  and it should be enough...
maybe we can create constructor like:
SQLTemplate(DataNode dataNode, String defaultTemplate) 
and few more things... why we need queryWithParameters...

Now to run code SQLTemplate I should write follow code:

String sql = "SELECT * FROM PersonTable WHERE Name = #bind($Name)";
Configuration config = Configuration.getSharedConfiguration();
DataDomain domain = config.getDomain();
DataMap anyDataMap = (DataMap) domain.getNode("MyNode").getDataMaps().iterator().next();
SQLTemplate query = new SQLTemplate(anyDataMap , sql);
Map parameters = new HashMap();
parameters.put("Name", "Eugene");
SQLTemplate newQuery = query.queryWithParameters(parameters);
List rowList = ctx.performQuery(newQuery);

It's huge and contains lot's of redundant operations... And it's hard to find this solution! We should add it to user guide....
We can do some Improvement to white this code:

String sql = "SELECT * FROM PersonTable WHERE Name = #bind($Name)";
Configuration config = Configuration.getSharedConfiguration();
DataDomain domain = config.getDomain();
Map parameters = new HashMap();
parameters.put("Name", "Eugene");
//here is new constructor: SQLTemplate(DataNode dataNode, String defaultTemplate, Map parameters)
SQLTemplate query = new SQLTemplate(domain.getNode("MyNode"), sql, parameters);  
List rowList = ctx.performQuery(newQuery);
	
It's more intuitive thing and doesn't requires redundant things!

Or I have alternative solution to make this code executable:

String sql = "SELECT * FROM PersonTable WHERE Name = #bind($Name)";
Configuration config = Configuration.getSharedConfiguration();
DataDomain domain = config.getDomain();
Map parameters = new HashMap();
parameters.put("Name", "Eugene");
//here is new constructor: SQLTemplate(DataNode dataNode, String defaultTemplate)
SQLTemplate query = new SQLTemplate(domain.getNode("MyNode"), sql, parameters);  
// pass parameters while performQuery to every query (not only while performing NamedQuery)
List rowList = ctx.performQuery(newQuery, parameters);

Also more comfortable thing... 

> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761491#action_12761491 ] 

Andrus Adamchik commented on CAY-1287:
--------------------------------------

Evgeny, I don't think this is an issue at all. Indeed SQLTemplate can be used without a root entity (or a Java class) attached to it.  However during execution we need to know which DataNode to run it against (the mapping can have more than one DataNode). So we still need that piece of information. And this is achieved by using the following constructor:

SQLTemplate(DataMap rootMap, String defaultTemplate)

Where rootMap is the DataMap that is linked to the desired DataNode. This should solve your problem I think.

> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Updated: (CAY-1287) Enchance SQLTemplate API and it's Documentation for forming not-mapping (DataRow) queries

Posted by Andrus Adamchik <an...@objectstyle.org>.
We had a mailing list discussion, and IIRC the only thing we are doing  
under this Jira is changing documentation. No code changes.

Andrus

On Nov 11, 2009, at 10:20 AM, Andrey Razumovsky (JIRA) wrote:

>
>     [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel 
>  ]
>
> Andrey Razumovsky updated CAY-1287:
> -----------------------------------
>
>    Fix Version/s:     (was: 3.0)
>                   3.1
>
> 3.0 cannot have API changes, moving to 3.1
>
> By the way, Evgeny, as Andrus mentioned, classes from o.a.c.query  
> package (any many others, like o.a.c.map) cannot have reference to  
> classes from o.a.c.access because last ones do not exist in cayenne- 
> client jar and not avaliable on ROP
>
>> Enchance SQLTemplate API and it's Documentation for forming not- 
>> mapping (DataRow) queries
>> -----------------------------------------------------------------------------------------
>>
>>                Key: CAY-1287
>>                URL: https://issues.apache.org/jira/browse/CAY-1287
>>            Project: Cayenne
>>         Issue Type: Improvement
>>         Components: Cayenne Core Library, Cayenne Documentation
>>   Affects Versions: 2.0 branch
>>           Reporter: Evgeny Ryabitskiy
>>            Fix For: 3.1
>>
>>
>> I wish to use nice SQLTemplate scripting engine for my simple not- 
>> mapping (DataRow) runtime-formed queries.
>> But now I should pass a DataObject to SQLTemplate constructor.
>> The question is: "For what?"
>> To do mapping???
>> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has  
>> no sense!
>> I want to add constructor like: SQLTemplate(String defaultTemplate,  
>> Map parameter)
>> and teach DataContext to perform such queries well.
>
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>


[jira] Updated: (CAY-1287) Enchance SQLTemplate API and it's Documentation for forming not-mapping (DataRow) queries

Posted by "Andrey Razumovsky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrey Razumovsky updated CAY-1287:
-----------------------------------

    Fix Version/s:     (was: 3.0)
                   3.1

3.0 cannot have API changes, moving to 3.1

By the way, Evgeny, as Andrus mentioned, classes from o.a.c.query package (any many others, like o.a.c.map) cannot have reference to classes from o.a.c.access because last ones do not exist in cayenne-client jar and not avaliable on ROP

> Enchance SQLTemplate API and it's Documentation for forming not-mapping (DataRow) queries
> -----------------------------------------------------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Cayenne Core Library, Cayenne Documentation
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.1
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Evgeny Ryabitskiy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761522#action_12761522 ] 

Evgeny Ryabitskiy commented on CAY-1287:
----------------------------------------

So the idea of this issue is to enhance API to make it more intuitive.... :)

> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761525#action_12761525 ] 

Andrus Adamchik commented on CAY-1287:
--------------------------------------

One example why this is a bad idea is because SQLTemplate is used in ROP, which has no notion of DataNode.

> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Evgeny Ryabitskiy (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Evgeny Ryabitskiy updated CAY-1287:
-----------------------------------

    Description: 
I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
But now I should pass a DataObject to SQLTemplate constructor.
The question is: "For what?"
To do mapping???
If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!

I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
and teach DataContext to perform such queries well.

  was:I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.


> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 1.2.5, 2.0.5, 3.0 beta 1, 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


RE: [jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by Рябицкий Евгений <er...@diasoft.ru>.

> Sure. Could you please send those as an email to this or the user  
> list. Having it on the list instead of Jira  
> provides a better chance it gets noticed.

CAY-1282 Use #result as optional directive for only few columns (not all). 

I've post a patch for it. It's working and looks nice for me ;)


CAY-1280 Explicitly setting BindValue JDBC type and Precision via API.

There was a discussion here in dev-mail list... still waiting you response there :)

> I may not be able to answer right away (busy with work), but  
> others may have answers faster.

It's Ok. I am also at work.


Evgeny Ryabitskiy.


Re: [jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Oct 2, 2009, at 3:28 PM, Рябицкий Евгений wrote:

> DataMap doesn't belong to DataNode?

It does not "belong", but is rather "linked to" a single DataNode.

> Still think that we can improve Cayenne query engine ;)

I don't disagree with such statement in general. There's lots of  
legacy API that we should clean up. I explained why this specific  
suggestion won't be a good idea though.

> P.S. Don't want to be annoying... but still looking forward to you  
> answers to my other issues... :)

Sure. Could you please send those as an email to this or the user  
list. I may not be able to answer right away (busy with work), but  
others may have answers faster. Having it on the list instead of Jira  
provides a better chance it gets noticed.

Cheers,
Andrus


RE: [jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by Рябицкий Евгений <er...@diasoft.ru>.
> How come you don't know which DataMap to use, but know which DataNode  
> to use? I would think that if you know the later, you'd definitely  
> know the former. Unless you have projects that are just DataNodes  
> without any DataMaps?

I use following code:

private static DataNode myProjectDataNode;
.........
static {
//static init block
Configuration config = Configuration.getSharedConfiguration();
DataDomain domain = config.getDomain();
myProjectDataNode = domain.getNode("MapNode);
}
.....

So I have my DataNode as a singleton instance for my whole application.
I can get DataNode from static getter every time. It's very comfortable.
I also have some DomainMaps (some Named Queries) but in some cases I just need to perform runtime-formed queries. So it's very confusing for me to pass ANYDomainMap to SQLTemplate constructor every time...
To be hones it was so confusing that I didn't guess to do it  :))))
And not only me...
When I was creating this issue I didn't know any nice solution...
I had NameQuery that was containing this: $DynamicQueryAsString
And pass there my runtime formed SQL string as a parameter...
Stupid annoying solution..... that is how this issue appeared...


> Queries  
> are designed to be run via an ObjectContext that can map to multiple  
> nodes, and can be executed from remote layers with no access to  
> DataNode

DataMap doesn't belong to DataNode?

I am generally using one connection (one DataNode). Looks like I missed something about Nodes and Maps...


> I can agree about better documentation, but now that I described how  
> it works, does it make sense? It is easier to create missing  
> documentation instead of changing the main framework assumptions.

Yeah... at least now I know some solution better then my "DynamicQuery"...
In this case we should fix docs first...
Still think that we can improve Cayenne query engine ;)

P.S. Don't want to be annoying... but still looking forward to you answers to my other issues... :)

Evgeny Ryabitskiy.

Re: [jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by Andrus Adamchik <an...@objectstyle.org>.
I am taking this to dev, as Jira is a poor medium for discussion.


On Oct 2, 2009, at 2:33 PM, Evgeny Ryabitskiy (JIRA) wrote:
> But it's also very confusing to developer course he don't know which  
> Map to Use and User Guide have nothing about it.

How come you don't know which DataMap to use, but know which DataNode  
to use? I would think that if you know the later, you'd definitely  
know the former. Unless you have projects that are just DataNodes  
without any DataMaps?


> We should write about it there!
>
> I have simple solution for it.. At least it's not confusing to new  
> developer.... :
>
> // new constructor using only DataNode
> public SQLTemplate(DataNode dataNode, String defaultTemplate) {
>     //use any DomainMap course there is no metter...
>     this(dataNode.getDomainMaps.iterator().next(), defaultTemplate);
> }

I explained why this is not going to work in Jira. Let me reiterate.  
Referencing DataNode in the user code is prohibited by design. Queries  
are designed to be run via an ObjectContext that can map to multiple  
nodes, and can be executed from remote layers with no access to  
DataNode. So Cayenne general purpose queries must not have API  
dependency on the DataNode. There's a level of indirection that I  
think is not that hard for the end user to use.

I can agree about better documentation, but now that I described how  
it works, does it make sense? It is easier to create missing  
documentation instead of changing the main framework assumptions.

Andrus

[jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Evgeny Ryabitskiy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761548#action_12761548 ] 

Evgeny Ryabitskiy commented on CAY-1287:
----------------------------------------

But it's also very confusing to developer course he don't know which Map to Use and User Guide have nothing about it.... We should write about it there!

I have simple solution for it.. At least it's not confusing to new developer.... :

// new constructor using only DataNode
public SQLTemplate(DataNode dataNode, String defaultTemplate) {
     //use any DomainMap course there is no metter...
     this(dataNode.getDomainMaps.iterator().next(), defaultTemplate);
}

> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Evgeny Ryabitskiy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761484#action_12761484 ] 

Evgeny Ryabitskiy edited comment on CAY-1287 at 10/1/09 11:22 PM:
------------------------------------------------------------------

So... why I set it to bug and not to a new feature....

If you look at Javadoc of SQLTemplate constructor, I can see:

    public SQLTemplate(Class rootClass, String defaultTemplate) {
        setDefaultTemplate(defaultTemplate);
        setRoot(rootClass);
    }

So lets look at setRoot(rootClass) method:

 /**
     * Sets the root of the query
     * 
     * @param value The new root
     * @throws IllegalArgumentException if value is not a String, ObjEntity, DbEntity,
     *             Procedure, DataMap, Class or null. < --- look here!
     */
    public void setRoot(Object value) {...... }

But (!!!) if I pass null it throws exception! Looks like it was expected before to work without mapping for queries....
but implementation not follows it.... 

      was (Author: apparition):
    So... why I set it bug and not a new feature....
If you look at Javadoc of SQLTemplate constructor, I can see:

    public SQLTemplate(Class rootClass, String defaultTemplate) {
        setDefaultTemplate(defaultTemplate);
        setRoot(rootClass);
    }

So lets look at setRoot(rootClass) method:

 /**
     * Sets the root of the query
     * 
     * @param value The new root
     * @throws IllegalArgumentException if value is not a String, ObjEntity, DbEntity,
     *             Procedure, DataMap, Class or null. < --- look here!
     */
    public void setRoot(Object value) {...... }

But (!!!) if I pass null it throws exception! Looks like it was expected before to work without mapping for queries....
but implementation not follows it.... 
  
> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAY-1287) Enchance SQLTemplate API and it's Documentation for forming not-mapping (DataRow) queries

Posted by "Evgeny Ryabitskiy (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Evgeny Ryabitskiy updated CAY-1287:
-----------------------------------

    Component/s: Cayenne Documentation
     Issue Type: Improvement  (was: New Feature)
        Summary: Enchance SQLTemplate API and it's Documentation for forming not-mapping (DataRow) queries  (was: SQLTemplate for not-mapping (DataRow) queries)

I have changed issue description to be more accurate...

> Enchance SQLTemplate API and it's Documentation for forming not-mapping (DataRow) queries
> -----------------------------------------------------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Cayenne Core Library, Cayenne Documentation
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1287) SQLTemplate for not-mapping (DataRow) queries

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761523#action_12761523 ] 

Andrus Adamchik commented on CAY-1287:
--------------------------------------

> But I don't see why we need a DomainMap? We could pass DataNode and it should be enough...
> maybe we can create constructor like:
> SQLTemplate(DataNode dataNode, String defaultTemplate) 

-1. Cayenne has layered structure and the bottom layers are intentionally isolated from the top layers.


> SQLTemplate for not-mapping (DataRow) queries
> ---------------------------------------------
>
>                 Key: CAY-1287
>                 URL: https://issues.apache.org/jira/browse/CAY-1287
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne Core Library
>    Affects Versions: 2.0 branch
>            Reporter: Evgeny Ryabitskiy
>             Fix For: 3.0
>
>
> I wish to use nice SQLTemplate scripting engine for my simple not-mapping (DataRow) runtime-formed queries.
> But now I should pass a DataObject to SQLTemplate constructor.
> The question is: "For what?"
> To do mapping???
> If my query is like: "SELECT max(id) as MAX_ID from Table1" it has no sense!
> I want to add constructor like: SQLTemplate(String defaultTemplate, Map parameter)
> and teach DataContext to perform such queries well.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.