Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to get a column with CDO
How to get a column with CDO [message #1852454] Tue, 17 May 2022 04:49 Go to next message
I S is currently offline I SFriend
Messages: 13
Registered: May 2022
Junior Member
Hi all, I'm starting to learn CDO and I have a question.
I have a table my_table with multiple columns like:
- cdo_id
- other columns
- my_id

I have the following Java code
String finalSql = "SELECT cdo_id, id FROM my_table;
CDOQuery query = view.createQuery( "sql", finalSql );


Is it possible to retrieve 2 columns using CDOQuery and populate my result list List<ArrayList<Integer>> queryResultList? If not, how can I do it? In general, my question is how to get multiple columns from my table?



Re: How to get a column with CDO [message #1852536 is a reply to message #1852454] Sun, 22 May 2022 10:28 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
You can add the following statement:

query.setParameter("mapQuery", true);


Each result is a Map with column names as kays and column values as values.

The test case org.eclipse.emf.cdo.tests.db.SQLQueryTest.testNonCDOObjectQueries_Complex_MAP() has an example, see https://git.eclipse.org/c/cdo/cdo.git/tree/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java#n374 .

Note that CDOIDs internally have long integer values, so your ArrayList<Integer> might not be able to store these values.



Previous Topic:Binary serialization to existing OutputStream
Next Topic:Mixing UUIDs and positional identifiers in one model
Goto Forum:
  


Current Time: Fri Apr 26 14:36:40 GMT 2024

Powered by FUDForum. Page generated in 0.03310 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top