I just found out about Speedment, a Java 8 Stream-based OR/M library, and have to say that I love the idea of it. No more crazy configurations or spending time sifting through 900 pages of Hibernation docs to find the right way to annotate my classes: Speedment just reads your database, generates Java classes for you and gives you a stream-based API to run DDL statements against them. Wicked cool.
However, the one big deal breaker is that it seems like you have to use the Speedment UI for configuring your DB connection. Furthermore, the docs don't seem to specify how you can do things like:
etc. Looking on GitHub I can't seem to find how the code is wired together from the UI to produce a configuration object. Just wondering if there's a way to configure Speedment sans UI (perhaps via JSON or YAML), and if so, what configurations are available.
It is possible to configure Speedment without the UI, but it requires some tinkering. Basically, to generate code from a database, you need to manually create a speedment.json-file and specify which schema to generate from manually.
pom.xml
-file and a src/main/java
-directory)./src/main/json/speedment.json
{
"config" : {
"name" : "yourproject",
"packageName" : "com.yourcompany",
"packageLocation" : "src/main/java/",
"dbmses" : [{
"name" : "db0",
"typeName" : "MySQL",
"ipAddress" : "127.0.0.1",
"port" : 3306,
"schemas" : [{
"name" : "your_db_schema"
}]
}]
}
}
Run the Maven goal: mvn speedment:reload -Ddbms.username=root -Dbms.password=password
(with the credentials for your database)
Finally, run the Maven goal: mvn speedment:generate
The first goal connects to the database and fills in any missing configuration details in the .json file. The second goal generates .java-code.
To disable a specific table, set the json-property "enabled" to false
. Youc an also disable individual columns this way.
If you want, you can now configure the generation directly in the .json-file and then regenerate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With