complex usage example - Database API

30 views
Skip to first unread message

Tia

unread,
May 17, 2010, 2:04:12 PM5/17/10
to gwt-mobile-webkit-users
I've walked through the HelloDatabase example provided, and have
successfully implemented a simple example reading and writing data in
a single table into our code.
I'm now looking for some more complex examples using multiple tables,
and returning more complex data structures involving data selected
from multiple tables.
What are the limitations/capabilities of the Database API/
DataService?

Do more complex examples exist which I could review?
Can more complex objects be returned from a SELECT type of statement?
Must the return always be a 'row'? I've looked at the example for
extending the JavaScriptObject (GenericRow), but this is still a very
flat object.

thanks for any pointers,
tia

--
You received this message because you are subscribed to the Google Groups "gwt-mobile-webkit-users" group.
To post to this group, send email to gwt-mobile-...@googlegroups.com.
To unsubscribe from this group, send email to gwt-mobile-webkit...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwt-mobile-webkit-users?hl=en.

Bart Guijt

unread,
May 17, 2010, 3:30:36 PM5/17/10
to gwt-mobile-...@googlegroups.com
Hi Tia,

I don't have more complex examples, like using multiple tables in a single (join) statement.

However, you should be able to use joins just as easily as you would use a simple SQL select statetement. Just keep in mind the following:
1) Stick to the SQLite3 syntax (see http://sqlite.org/lang.html and specifically, http://sqlite.org/lang_select.html)
2) Query the GenericRow result object (or create your own class) mapped to the result-columns of the SELECT statement.

e.g. (untested):

@Select("SELECT user.name as name, user.email as email, order.amount as amount FROM user INNER JOIN order ON user.id = order.userId")
void getOrderAmounts(ListCallback<GenericRow> result);

would imply the following call:

service.getOrderAmounts(new ListCallback<GenericRow>() {
public boolean onFailure(SQLError e) {
return true;
}
public void onSuccess(List<GenericRow> result) {
for (GenericRow row : result) {
// Available attributes:
// row.getString("name")
// row.getString("email")
// row.getDouble("amount")
}
}
});

or something like that :-)

Is this example what you're looking for?


Cheers,

Bart Guijt
E: bgu...@gmail.com
T: +31 6 30408987

Tia

unread,
May 17, 2010, 5:43:25 PM5/17/10
to gwt-mobile-webkit-users
thanks for the response.
i think i'm looking for an ORM solution to abstract some of this
work. is there something you can suggest? or will i need to roll my
own?

thanks,
tia

On May 17, 12:30 pm, Bart Guijt <bgu...@gmail.com> wrote:
> Hi Tia,
>
> I don't have more complex examples, like using multiple tables in a single (join) statement.
>
> However, you should be able to use joins just as easily as you would use a simple SQL select statetement. Just keep in mind the following:
> 1) Stick to the SQLite3 syntax (seehttp://sqlite.org/lang.htmland specifically,http://sqlite.org/lang_select.html)
> > For more options, visit this group athttp://groups.google.com/group/gwt-mobile-webkit-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "gwt-mobile-webkit-users" group.
> To post to this group, send email to gwt-mobile-...@googlegroups.com.
> To unsubscribe from this group, send email to gwt-mobile-webkit...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/gwt-mobile-webkit-users?hl=en.

Bart Guijt

unread,
May 18, 2010, 3:24:43 AM5/18/10
to gwt-mobile-webkit-users
AFAIK, there is no ORM solution available on top of this API. You'll
need to roll your own :-)

Bart.

On May 17, 11:43 pm, Tia <cyclechic...@gmail.com> wrote:
> thanks for the response.
> i think i'm looking for an ORM solution to abstract some of this
> work.  is there something you can suggest? or will i need to roll my
> own?
>
> thanks,
> tia
>
> On May 17, 12:30 pm, Bart Guijt <bgu...@gmail.com> wrote:
>
>
>
>
>
> > Hi Tia,
>
> > I don't have more complex examples, like using multiple tables in a single (join) statement.
>
> > However, you should be able to use joins just as easily as you would use a simple SQL select statetement. Just keep in mind the following:
> > 1) Stick to the SQLite3 syntax (seehttp://sqlite.org/lang.htmlandspecifically,http://sqlite.org/lang_select.html)
Reply all
Reply to author
Forward
0 new messages