Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Getting number of affected rows after an SQLContainer commit()
I'm commiting changes and new records into a database with an SQLContainer commit(). Sometimes it would be interesting to know the number of affected rows by the operation, to check its successfulness, specially when this method "fails" or, at least, does nothing silently.
For instance, I commit my data coming from a FormField, creating an empty Item, and when it gets commited it seems that item "disappears" and cannot be reused to insert new records by simply reusing the form and clicking the submit button, but I have yet to find a method to do so - probably involving creating a new, fresh item and rebinding it to the form or whatever. Anyway, as the commit() method wasn't failing and it reports NOTHING about not being items to update/insert/delete, I didn't understood what was happening.
Is there any way to, for instance, get the count of the removedItems / addedItems / modifiedItems private collections I see in the source code of SQLContainer or is there a better method to accomplish this?
there are no such methods as far as I can tell, and since members are private, you can't even access them in a subclass. Sounds like a reasonable feature request - do you mind creating a ticket in GitHub?
I can live without those features and, in fact, I've continued my development without minding it too much, although I would had used them had they been available at the moment for adding a bit more robustness when treating some unexpected behaviour.
Anyway, I'd create a feature request if it's useful for someone. But how do you do that? I've filled bugs before, but never made a feature request in GitHub. Does it work the same way?
Yep, same way as bug reports. They can be tagged later to specify the issue type (most bugs should have the "bug" tag for example)
Ok, I did it here:
Although I'm getting very depressed after reading somwhere in your blog that SQLContainer is gonna be removed in Vaddin 8... WTF?!?!?
It'll still be there in the compatibility package. But data binding in general is going to be overhauled in Vaadin 8 in a major way. Stay tuned for more news on the topic!