I like to use embedded derby db for testing.
Since Vaadin’s SQLContainer lacks of Derby-support I wrote a simple SQLGenerator for Derby. It so simple, wasn’t worth packaging.
Here it is, not thoroughly tested, works for my use cases so far. Just copy to your project.
import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator;
/**
* @author Janko Dimitroff
*/
@SuppressWarnings("serial")
public class DerbySQLGenerator extends DefaultSQLGenerator {
public DerbySQLGenerator() {
}
/** Construct a DerbySQLGenerator with the specified identifiers for start and end of quoted strings. The identifiers
* may be different depending on the database engine and it's settings.
*
* @param quoteStart the identifier (character) denoting the start of a quoted string
* @param quoteEnd the identifier (character) denoting the end of a quoted string */
public DerbySQLGenerator(String quoteStart, String quoteEnd) {
super(quoteStart, quoteEnd);
}
/** Generates the LIMIT and OFFSET clause.
*
* @param sb StringBuffer to which the clause is appended.
* @param offset Value for offset.
* @param pagelength Value for pagelength.
* @return StringBuffer with LIMIT and OFFSET clause added. */
protected StringBuffer generateLimits(StringBuffer sb, int offset, int pagelength) {
sb.append(" OFFSET ").append(offset).append(" ROWS").append(" FETCH NEXT ").append(pagelength).append(" ROWS ONLY");
return sb;
}
}