Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

How to define boolean attributes in my extension

$
0
0
I am trying to write a Liquibase extension with a tag that has a boolean attribute.

The XSD for that change looks like this:

  1. <xsd:element name="createFoo">
  2.   <xsd:complexType>
  3.     <xsd:attribute name="name" type="xsd:string" use="required"/>
  4.     <xsd:attribute name="isBaseType" type="xsd:boolean"/>
  5.   </xsd:complexType>
  6. </xsd:element>


The changeSet for that contains the following entry:

  1. <ext:createFoo name="Number" isBaseType="true"/>

My Change implementation looks like this:

  1. @DatabaseChange(name = "createFoo", priority = ChangeMetaData.PRIORITY_DEFAULT)
  2. public class CreateFooChange
  3.     extends AbstractChange {
  4.    
  5.     private String name;
  6.     private boolean isBaseType;

  7.     @DatabaseChangeProperty
  8.     public boolean isBaseType() {
  9.         return isBaseType;
  10.     }
  11.     public void setBaseType(boolean flag) {
  12.         this.isBaseType = flag;
  13.     }

  14.     @DatabaseChangeProperty
  15.     public String getName() {
  16.         return name;
  17.     }
  18.     public void setName(String name) {
  19.         this.name = name;
  20.     }
  21.     ... some more methods ....
  22. }

However when I run Liquibase, if fails with the following error:

  1. SEVERE 22/03/2018, 11:02: liquibase: Cannot convert java.lang.String 'true' to boolean
  2. liquibase.exception.ChangeLogParseException: liquibase.exception.UnexpectedLiquibaseException: Cannot convert java.lang.String 'true' to boolean
  3.     at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:27)
  4.     at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:229)
  5.     at liquibase.Liquibase.update(Liquibase.java:202)
  6.     at liquibase.Liquibase.update(Liquibase.java:277)
  7.     at liquibase.Liquibase.update(Liquibase.java:258)
  8.     at liquibase.integration.commandline.Main.doMigration(Main.java:1156)
  9.     at liquibase.integration.commandline.Main.run(Main.java:188)
  10.     at liquibase.integration.commandline.Main.main(Main.java:103)
  11.     at com.mgmtp.a12.liquibase.RunMe.main(RunMe.java:21)
  12. Caused by: liquibase.exception.UnexpectedLiquibaseException: Cannot convert java.lang.String 'true' to boolean
  13.     at liquibase.parser.core.ParsedNode.convertObject(ParsedNode.java:259)
  14.     at liquibase.parser.core.ParsedNode.getChildValue(ParsedNode.java:222)
  15.     at liquibase.change.AbstractChange.load(AbstractChange.java:634)
  16.     at liquibase.changelog.ChangeSet.toChange(ChangeSet.java:441)
  17.     at liquibase.changelog.ChangeSet.handleChildNode(ChangeSet.java:380)
  18.     at liquibase.changelog.ChangeSet.load(ChangeSet.java:311)
  19.     at liquibase.changelog.DatabaseChangeLog.createChangeSet(DatabaseChangeLog.java:513)
  20.     at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:311)
  21.     at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:282)
  22.     at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)
  23.     ... 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?





Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>