You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Andrus Adamchik <an...@objectstyle.org> on 2009/10/02 13:43:41 UTC

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

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

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.