final ObjectFactory objectFactory = new ObjectFactory();
final SqlResourceDefinition def = objectFactory.createSqlResourceDefinition();
final Query query = objectFactory.createQuery();
def.setQuery(query);
final MetaData metaData = objectFactory.createMetaData();
final Database database = objectFactory.createDatabase();
database.setDefault(databaseName);
metaData.setDatabase(database);
final Table table = objectFactory.createTable();
table.setRole("Parent");
metaData.getTable().add(table);
def.setMetadata(metaData);