I am trying to write a Liquibase extension with a tag that has a boolean attribute.
The XSD for that change looks like this:
The XSD for that change looks like this:
- <xsd:element name="createFoo">
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="isBaseType" type="xsd:boolean"/>
- </xsd:complexType>
- </xsd:element>
The changeSet for that contains the following entry:
- <ext:createFoo name="Number" isBaseType="true"/>
My Change implementation looks like this:
- @DatabaseChange(name = "createFoo", priority = ChangeMetaData.PRIORITY_DEFAULT)
- public class CreateFooChange
- extends AbstractChange {
- private String name;
- private boolean isBaseType;
- @DatabaseChangeProperty
- public boolean isBaseType() {
- return isBaseType;
- }
- public void setBaseType(boolean flag) {
- this.isBaseType = flag;
- }
- @DatabaseChangeProperty
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- ... some more methods ....
- }
However when I run Liquibase, if fails with the following error:
- SEVERE 22/03/2018, 11:02: liquibase: Cannot convert java.lang.String 'true' to boolean
- liquibase.exception.ChangeLogParseException: liquibase.exception.UnexpectedLiquibaseException: Cannot convert java.lang.String 'true' to boolean
- at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:27)
- at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:229)
- at liquibase.Liquibase.update(Liquibase.java:202)
- at liquibase.Liquibase.update(Liquibase.java:277)
- at liquibase.Liquibase.update(Liquibase.java:258)
- at liquibase.integration.commandline.Main.doMigration(Main.java:1156)
- at liquibase.integration.commandline.Main.run(Main.java:188)
- at liquibase.integration.commandline.Main.main(Main.java:103)
- at com.mgmtp.a12.liquibase.RunMe.main(RunMe.java:21)
- Caused by: liquibase.exception.UnexpectedLiquibaseException: Cannot convert java.lang.String 'true' to boolean
- at liquibase.parser.core.ParsedNode.convertObject(ParsedNode.java:259)
- at liquibase.parser.core.ParsedNode.getChildValue(ParsedNode.java:222)
- at liquibase.change.AbstractChange.load(AbstractChange.java:634)
- at liquibase.changelog.ChangeSet.toChange(ChangeSet.java:441)
- at liquibase.changelog.ChangeSet.handleChildNode(ChangeSet.java:380)
- at liquibase.changelog.ChangeSet.load(ChangeSet.java:311)
- at liquibase.changelog.DatabaseChangeLog.createChangeSet(DatabaseChangeLog.java:513)
- at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:311)
- at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:282)
- at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)
- ... 8 more
I also tried to define the instance variables as Boolean. In that case the error during runtime goes away, but my property is never populated with the value from the changeSet.
What am I missing here?