Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-23 Thread Kumar
use DummyPositionRecord.class in a normal SelectQuery as > the DBEntity doesn't exist. > > > > Remember to document your code ;-) > > > > Regards > > Jurgen > > > > > > > > -Original Message- From: Kumar > > Sent: Wednesday, Decem

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-23 Thread Andrus Adamchik
u can't use DummyPositionRecord.class in a normal SelectQuery as the > DBEntity doesn't exist. > > Remember to document your code ;-) > > Regards > Jurgen > > > > -Original Message----- From: Kumar > Sent: Wednesday, December 21, 2016 6:42 PM >

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-23 Thread Kumar
select field clause has to specify >> all these fields: >> >> buyer_account >> exch_tools_trade_num >> external_trade_oid >> port_num >> >> Regards >> Jurgen >> >> >> From: Kumar >> Sent: Friday, December 23, 2016 1:12 PM >> To: u

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-23 Thread Kumar
rade_oid where ett.external_trade_oid > > 18853859"); > > > > Also attached the Modeler generated files. > > > > > Thanks, > Kumar > > On Fri, Dec 23, 2016 at 1:45 PM, wrote: > > Hi Kumar > > Glad it worked :-) > I don't

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-23 Thread Kumar
num > external_trade_oid > port_num > > Regards > Jurgen > > > From: Kumar > Sent: Friday, December 23, 2016 1:12 PM > To: user@cayenne.apache.org > Subject: Re: How to define a raw sql in the datamap.xml file and use it > through SQLTemplate > > Hey > &

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-23 Thread dollj
@cayenne.apache.org Subject: Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate Hey One problem what i'm facing is if i say * in my select query it is working but not when i specify the column name. May be i'm wrong in specifying the col name? This is w

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-23 Thread Kumar
x27;t have any knowledge of Hibernate so I cannot say. > Maybe someone else on the list can comment ? > > Regards > Jurgen > > -Original Message- From: Kumar > Sent: Friday, December 23, 2016 8:12 AM > To: user@cayenne.apache.org > Subject: Re: How to define a raw s

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-23 Thread dollj
ql in the datamap.xml file and use it through SQLTemplate Hey, I tried your solution and its working. Thanks again. I can save a few lines of code now. Can i take this as a equivalent to the below which i was using in Hibernate. *sqlQueryToFetchPositions.setResultTransformer(Transformers.aliasT

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-22 Thread Kumar
Record.class, sql ); > > Note, you can't use DummyPositionRecord.class in a normal SelectQuery as > the DBEntity doesn't exist. > > Remember to document your code ;-) > > Regards > Jurgen > > > > -Original Message- From: Kumar > Sent: Wednesday, December

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-22 Thread Kumar
); > > Note, you can't use DummyPositionRecord.class in a normal SelectQuery as > the DBEntity doesn't exist. > > Remember to document your code ;-) > > Regards > Jurgen > > > > -Original Message----- From: Kumar > Sent: Wednesday, December 21, 201

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread dollj
ber to document your code ;-) Regards Jurgen -Original Message- From: Kumar Sent: Wednesday, December 21, 2016 6:42 PM To: user@cayenne.apache.org Subject: Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate Guys, Let me refine my question and tel

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread John Huss
You can't do it directly (unless some very recent addition to Cayenne makes this possible). You can return DataRows and then use reflection to copy the data to the object using PropertyUtils.setProperty (assuming the names are the same). On Wed, Dec 21, 2016 at 10:43 AM Kumar wrote: > Guys, >

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread Kumar
Guys, Let me refine my question and tell you the exact requirement. I have an UI control (TableView) where i need to display records which are fetched from DB. For the TableView UI control i need to tell the java class from which it should pick the values for each column. So each properties gette

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread John Huss
You need to specify which ObjEntity this is supposed to create in the DataMap query. On Wed, Dec 21, 2016 at 9:22 AM Kumar wrote: > Hey > Even with NamedQuery i face the same issue. > *Exception in thread "main" org.apache.cayenne.CayenneRuntimeException: > [v.4.0.M4.ce40fc0 Oct 26 2016 22:22:5

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread Kumar
Hey Even with NamedQuery i face the same issue. *Exception in thread "main" org.apache.cayenne.CayenneRuntimeException: [v.4.0.M4.ce40fc0 Oct 26 2016 22:22:58] Set up Object entity or use rowFetchingQuery* final NamedQuery namedQuery = new NamedQuery("PositionWithoutBuyerAccount"); final List x =

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread Andrus Adamchik
To be clear MappedSelect is a 4.0 analog of the older NamedQuery, only with better API. So John's advice stands. Andrus > On Dec 21, 2016, at 6:13 PM, John Huss wrote: > > I haven't used MappedQuery, which may be a better solution. But here is > the old-school way to do it. > http://cayenne.

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread John Huss
I haven't used MappedQuery, which may be a better solution. But here is the old-school way to do it. http://cayenne.apache.org/docs/3.0/namedquery.html You don't have to fetch DataRows, but be aware that you can only materialize one type of Entity at a time. And for performance you should be sur

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread Kumar
I know setting the below property will solve the problem but i don't want DataRows to be return instead i want my persistent entity type. Thanks! Kumar ​

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread Kumar
Hey Dima, Thanks for replying. But i don't think i understood your answer totally. As i said, it is a native SQL with multiple joins and "if exists" clauses. SELECT* et.** FROM external_trade et, exch_tools_trade ett,external_trade_state ets WHERE (et.external_trade_system_oid IN (1)) AND (et.ex

Re: How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread Dzmitry Kazimirchyk
Hello Kumar, Currently it is not possible to extract a query defined in the datamap as an SQLTemplate query instance. MappedSelect is a separate type of query which represents all the query types that can be defined in the datamap and the idea behind it is that after defining your query in t

How to define a raw sql in the datamap.xml file and use it through SQLTemplate

2016-12-21 Thread Kumar
Hey, I have defined few queries in the datamap.xml file and and accessing it using MappedSelect.query("queryName") My quick question is, I want to define a native sql query in the datamap.xml file and to access in the code. Currently MappedSelect.query() is returning a MappedSelect which i cannot