diffDatabaseToChangeLog problem with Decimal

Hi Nathan, thanks for the reply.


currently use hbm2ddl for generate sql, but I want to change liquibase.


BigDecimal error occurs when run diffDatabaseToChangeLog between 2 schemas from the database. I have a schema with the latest version of the database in development and another with the production version.


Is there any way to use liquibae if I use hibernate with usertype?

any idea?

Actually I have 2 problems


1.- I tried using hibernate diffDatabaseToChangeLog with but as I use usertype  I get an error.


Is there any way to use liquibase if I use hibernate usertype?



2.- To get the delta between objects in hibernate and database development, I create the full database in another schema and I use diffDatabaseToChangeLog to get the changelog. doing this gives me the following error:


  1. liquibase.exception.UnexpectedLiquibaseException: Unknown object type java.math.BigDecimal

ant task


any idea?


I use MySQL 5.1, the data type is DECIMAL(15,3),

liquibase-2.0.1.jar

liquibase-hibernate-2.0.0.jar



Unfortunately, the hibernate diff may not work with usertypes. I have not tried them, so we may need to do something specific, beyond the standard hbm2ddl logic we normally use. Is the BigDecimal error in question #2 the error you were seeing due to the usertype?

Nathan

I had the same error while comparing two schemas. 


One schema had an extra NUMERIC column which contained a default value of 0. This was translated two java.math.BigDecimal, but while creating the “MissingColumnChange” the datatype has to be transferred back to a database type, which for BigDecimal throws an exception.


I extended the getDataType method to return getNumberType in case of object being an instanceof BigDecimal. So far, the problem seems to be solved.

I experienced the same issue without using it with Hibernate, on postgres.

The original schema has a new field, type double not null default 0.00. When I run the diffChangeLog I receive:

Liquibase Update Failed: Unknown object type java.math.BigDecimal
SEVERE 10/3/12 9:47 AM:liquibase: Unknown object type java.math.BigDecimal
liquibase.exception.UnexpectedLiquibaseException: Unknown object type java.math.BigDecimal
    at liquibase.database.typeconversion.core.AbstractTypeConverter.getDataType(AbstractTypeConverter.java:60)
    at liquibase.diff.DiffResult.addMissingColumnChanges(DiffResult.java:856)
    at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:484)
    at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:411)
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:134)
    at liquibase.integration.commandline.Main.doMigration(Main.java:757)
    at liquibase.integration.commandline.Main.main(Main.java:134)

It succeeded when I removed both the default value and the “not null” constraint.

I’m running into this after I created several domain classes in grails. It would be helpful if the exception points out where in the changelog the problem is. Right now I am clueless.