I’d like to know how to configure a property with Managed
type referred by another Managed
object in model block.
There are two Managed
models, one of them refers to the other.
The former interface is like…
@Managed
public interface JpaUnit {
String getUnit();
void setUnit(String unit);
Database getDb();
void setDb(Database db);
}
And the later is like…
@Managed
public interface Database {
String getDriver();
void setDriver(String driver);
String getUrl();
void setUrl(String url);
}
And a class which extends RuleSource
is like…
class Foo extends RuleSource {
@Model
void jpaUnit(JpaUnit u) {}
@Model
void db(Database d) {}
}
I tried…
model {
jpaUnit {
unit = 'test'
db {
driver = 'org.h2.Driver'
url = 'jdbc:h2:tcp://localhost:9092/~/h2/sample'
}
}
}
But this script doesn’t work because there is no db()
method in closure which is given to jpaUnit
.
And when I changed modle
block then the property db
is null
so I can’t configure db
property.
model {
jpaUnit {
unit = 'test'
db.driver = 'org.h2.Driver'
db.url = 'jdbc:h2:tcp://localhost:9092/~/h2/sample'
}
}
So I’m wondering how to configure Managed
object referred by another Managed
object.