Try exposing the primary key columns with:
((JDBCFeatureSource)
featureSource).setExposePrimaryKeyColumns(true);
Also use "" around the ID-column names.And use table aliases in the filter (not
really necessary in your case but in that way you can use ID as PK-column-name
in all your tables):
filterFactory.equals(filterFactory.property("TABLE_A.\"ID_A\"",
filterFactory.property("TABLE_B.\"ID_B\"")));
Ron
On Wednesday, 12 November 2014, 7:50, fmd85 <florian-di...@gmx.de> wrote:
Hi,
i'm trying to join two tables in a Query. They should be joined with their
primary keys. If i define the join in the query i get an
IllegalArgumentException, Attribute "ID_A" not present in table A or table B
(defining Filters on a primary key column also fails).
*The tables:*
Columns Table A:
ID_A (Primary Key), HISTORICAL, YEAR, COMPANYNR
Columns Table B:
ID_B (Primary Key), GEOM (Geometry)
*This is my code:*
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
Query query = new Query("TABLE_A");
List<Filter> filterList = new ArrayList<Filter>();
filterList.add(ff.isNull(ff.property("HISTORICAL")));
filterList.add(ff.equal(ff.property("YEAR"), ff.literal(2014)));
filterList.add(ff.like(ff.property("COMPANYNR"), bnr + "%"));
Join join = new Join("B", ff.equals(ff.property("ID_A"),
ff.property("ID_B")));
query.getJoins().add(join);
query.setFilter(ff.and(filterList));
I guess that the primary key of a table can't be used like normal a column
in Joins and Filters, but i didn't find the answer how to use the primary
key columns in these expressions. Does anybody know how to do it?
Thanks for your help,
Max
--
View this message in context:
http://osgeo-org.1560.x6.nabble.com/Join-on-Primary-Keys-in-a-Query-tp5172471.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users