-
Notifications
You must be signed in to change notification settings - Fork 10
Home
Reladomo, which stands for "Relational Domain Objects", is an enterprise grade object-relational mapping (ORM) Framework for Java with the following enterprise features:
- Strongly typed compile-time checked query language
- Bi-temporal chaining
- Transparent multi-schema support
- Full support for unit-testable code
- See the documentation for more detail: https://goldmansachs.github.io/reladomo/
The reladomo-scala
library from FOLIO Co., Ltd. is a Scala library which provides an idiomatic way to use Reladomo in Scala.
sbt new folio-sec/reladomo-first-example.g8
lazy val root = (project in file("."))
.settings(
scalaVersion := "2.12.4",
libraryDependencies ++= Seq(
"com.folio-sec" %% "reladomo-scala-common" % "{latest version}",
"com.h2database" % "h2" % "1.4.196",
"org.scalatest" %% "scalatest" % "3.0.4" % "test"
)
)
.enablePlugins(ReladomoPlugin)
addSbtPlugin("com.folio-sec" % "sbt-reladomo-plugin" % "{latest version}")
Supported sbt versions: 0.13.x, 1.0.x
sbt.version=0.13.7
sbt-reladomo-plugin automatically scans all files named as ReladomoClassList.xml
under resources directories.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Mithra xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/reladomo/reladomoobject.xsd" enableOffHeap="false">
<MithraObjectResource name="Person"/>
</Mithra>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MithraObject objectType="transactional" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/reladomo/reladomoobject.xsd">
<PackageName>com.folio_sec.example.domain.people</PackageName>
<ClassName>Person</ClassName>
<DefaultTable>PERSON</DefaultTable>
<Attribute name="personId" javaType="int" columnName="PERSON_ID" primaryKey="true" primaryKeyGeneratorStrategy="Max"/>
<Attribute name="firstName" javaType="String" columnName="FIRST_NAME" nullable="false" maxLength="64"/>
<Attribute name="lastName" javaType="String" columnName="LAST_NAME" nullable="false" maxLength="64"/>
<Attribute name="country" javaType="String" columnName="COUNTRY" nullable="false" maxLength="48"/>
</MithraObject>
This project provides an sbt plugin and runtime modules.
addSbtPlugin("com.folio-sec" % "sbt-reladomo-plugin" % "{latest version}")
The sbt plugin is mandatory to use. The plugin does the following tasks beforehand while Scala compilation:
- generates both Java and Scala code from Reladomo configuration files
- generates DDLs from Reladomo configuration files
The generated source files are placed under target/scala-{scala bin version}/src_managed/main
directory by default and are managed to be in the classpath during compilation.
Default enables the following settings. You can modify any of them in your build.sbt
.
lazy val baseSettings: Seq[Def.Setting[_]] = Seq(
reladomoGen := reladomoGenTask.value,
// the directory to scan reladomo configuration XML files
reladomoXmlFilesDir := resourceDirectory.value / "reladomo",
// the name to be scanned as `ReladomoClassList.xml` files
reladomoClassListXmlFileName := "ReladomoClassList.xml",
// the directory to output DDLs from Reladomo configurations
reladomoDbDefinitionFilesDir := resourceDirectory.value / "reladomo" / "db_definition",
// the database type which is used for DDLs generation
reladomoDbDefinitionDatabaseType := "mysql",
// the suffix part which isused for the package for generated Scala API classes/traits
reladomoScalaApiPackageSuffix := "scala_api",
// the directory to output modifiable Java source code
reladomoModifiableJavaCodeOutputDir := (javaSource in Compile).value,
// the directory to output modifiable Scala source code
reladomoModifiableScalaCodeOutputDir := (scalaSource in Compile).value,
// the directory to output unmodifiable source code
reladomoUnmodifiableFilesOutputDir := (sourceManaged in Compile).value,
// the flag to enable DDLs generation
reladomoDbDefinitionGenerationEnabled := true,
// the type which indicates what Future APIs to be used for generated Scala Services
reladomoScalaApiFutureType := "scala-lang" // or "twitter"
)
If your application uses reladomo-scala
library, your application needs to depend on this module at runtime. The module provides:
-
DatabaseManager
- provides an extended runtime configuration loader
- provides accessors to loaded
ConnectionManager
runtime
-
TransactionalObject
,TransactionalList
,TransactionalObjectFinder
- provides Scala APIs which encapsulate
MithraTransactionalObject
andMithraTransactionalList
- provides Scala APIs which encapsulate
-
BiTemporalTransactionalList
,BiTemporalTransactionalObjectFinder
- provides Scala APIs which encapsulate
MithraTransactionalObject
andMithraTransactionalList
- provides Scala APIs which encapsulate
-
TransactionProvider
- provides smooth Scala APIs which provide
MithraManager
's transactional blocks
- provides smooth Scala APIs which provide
-
TransactionalObjectService
,BiTemporalTransactionalObjectService
- provides the standard Future wired Scala APIs using
TransactionalObject
,TransactionalList
,TransactionalObjectFinder
- provides the standard Future wired Scala APIs using
If your application needs to depend on com.twitter.util.Future
at runtime, adding this optional module and having reladomoScalaApiFutureType in Compile := "twitter"
in sbt settings are mandatory.
The module has only two traits:
-
TransactionalObjectService
,BiTemporalTransactionalObjectService
- provides com.twitter.util.Future wired Scala APIs using
TransactionalObject
,TransactionalList
,TransactionalObjectFinder
- provides com.twitter.util.Future wired Scala APIs using
The following build.sbt
is a sample to use twitter-common at a time.
lazy val reladomoScalaV = "{latest version}"
lazy val root = (project in file("."))
.settings(
scalaVersion := "2.12.4",
libraryDependencies ++= Seq(
"com.folio-sec" %% "reladomo-scala-common" % reladomoScalaV,
"com.folio-sec" %% "reladomo-scala-twitter-6.45-common" % reladomoScalaV,
"com.h2database" % "h2" % "1.4.196" % "test",
"org.scalatest" %% "scalatest" % "3.0.4" % "test"
),
reladomoScalaApiFutureType in Compile := "twitter"
)
.enablePlugins(ReladomoPlugin)