Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Getting item by a primary key in SQLContainer

Karolis Lesickas
10 years ago Mar 28, 2012 11:23am
Teppo Kurki
10 years ago Mar 28, 2012 11:35am

Hi,

if your database is correctly configured (I mean that there is at least one primary key column defined) the item IDs you get from SQLContainer should be of type RowId. You can call getId() for this RowId and you will get back an Object array containing the value(s) of the primary key column(s).

So in reverse, if you know the primary key of the item in the database, you could get it like this (assumes you have one primary key column in the table):

SQLContainer.getItem(new RowId(new Object[]{"foo"}));

where "foo" is the primary key value of the row you want to fetch.

-Tepi

Last updated on Mar, 28th 2012
Karolis Lesickas
10 years ago Mar 28, 2012 11:41am
Hemant Ghaydar
6 years ago Apr 25, 2015 3:41am
Teppo Kurki
6 years ago Apr 27, 2015 7:02am
Hemant Ghaydar
6 years ago Apr 27, 2015 4:09pm
Hemant Ghaydar
6 years ago Apr 27, 2015 4:13pm
Jan Scheer
5 years ago Mar 09, 2017 2:29pm