use of org.jaxdb.ddlx.DDLx in project jaxdb by jaxdb.
the class SQL method ddlx2xsd.
public static void ddlx2xsd(final URL ddlxUrl, final File xsdFile) throws IOException, TransformerException {
xsdFile.getParentFile().mkdirs();
try {
final DDLx ddlx = new DDLx(ddlxUrl);
Transformer.transform(resource, ddlx.getMergedXml(), ddlx.getUrl().toString(), xsdFile);
} catch (final SAXException e) {
throw new RuntimeException(e);
}
}
use of org.jaxdb.ddlx.DDLx in project jaxdb by jaxdb.
the class SQLxTest method loadData.
public static int[] loadData(final Connection connection, final String name) throws IOException, SAXException, SQLException, TransformerException {
final DDLx ddlx = new DDLx(ClassLoader.getSystemClassLoader().getResource(name + ".ddlx"));
Schemas.truncate(connection, ddlx.getMergedSchema().getTable());
final URL sqlx = ClassLoader.getSystemClassLoader().getResource("jaxdb/" + name + ".sqlx");
assertNotNull(name, sqlx);
return SQL.INSERT(connection, ($Database) Bindings.parse(sqlx));
}
use of org.jaxdb.ddlx.DDLx in project jaxdb by jaxdb.
the class JSqlTest method createEntities.
static void createEntities(final String name) throws CompilationException, GeneratorExecutionException, IOException, SAXException, TransformerException {
final URL url = assertNotNull(ClassLoader.getSystemClassLoader().getResource(name + ".ddlx"));
final File destDir = new File("target/generated-test-sources/jaxdb");
Generator.generate(url, name, destDir);
final InMemoryCompiler compiler = new InMemoryCompiler();
Files.walk(destDir.toPath()).filter(p -> p.getFileName().toString().endsWith(".java")).forEach(rethrow((Path p) -> compiler.addSource(new String(Files.readAllBytes(p)))));
compiler.compile(destDir, "-g");
}
use of org.jaxdb.ddlx.DDLx in project jaxdb by jaxdb.
the class JSqlTest method loadEntitiesJaxSB.
@SuppressWarnings("unchecked")
static int loadEntitiesJaxSB(final Connection connection, final String name) throws ClassNotFoundException, IOException, SAXException, SQLException, TransformerException {
Database.threadLocal((Class<? extends Schema>) Class.forName(Entities.class.getPackage().getName() + "." + name)).connectPrepared(() -> connection);
final URL sqlx = ClassLoader.getSystemClassLoader().getResource("jaxdb/" + name + ".sqlx");
assertNotNull(sqlx);
final $Database database = ($Database) Bindings.parse(sqlx);
final DDLx ddlx = new DDLx(ClassLoader.getSystemClassLoader().getResource(name + ".ddlx"));
Schemas.truncate(connection, ddlx.getMergedSchema().getTable());
final Batch batch = new Batch();
final int expectedCount = DBVendor.valueOf(connection.getMetaData()) == DBVendor.ORACLE ? 0 : 1;
for (final data.Table<?> table : Entities.toEntities(database)) batch.addStatement(INSERT(table), (e, c) -> assertEquals(expectedCount, c));
return batch.execute();
}
Aggregations