Problem when trying to use Liquibase with Hibernate (EJB3/JPA)

Hello :slight_smile:
Trying to use liquibase on a project but got some troubles.

My problem looks like this one:
http://www.opensource-archive.org/archive/index.php/t-33590.html

I’m trying to use an Ant script:

    <target name="aaa_test-hibernate-update" >
    	
    	<taskdef resource="liquibasetasks.properties">
    		<classpath>
    			<fileset dir="${core.lib.build.liquibase}">
    				<include name="*.jar"/>
    			</fileset>
    		</classpath>
    	</taskdef>
     
    &nbsp; &nbsp; <diffDatabaseToChangeLog
    &nbsp; &nbsp; 	driver="${db.driver}"
    &nbsp; &nbsp; 	url="${db.url}"
    		username="${db.user}"
    		password="${db.pass}"
    		baseUrl="hibernate:${core.etc}/META-INF/persistence.xml"
    &nbsp; &nbsp; 	outputFile="changelog.xml"
    &nbsp; &nbsp; 	classpathref="core.full.classpath" >
    &nbsp; &nbsp; 	
    &nbsp; &nbsp; </diffDatabaseToChangeLog>
    </target></ol>
    

    I get the following error:

    /home/slorber/workspace/build-xxx/build.xml:871: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

    I use eclipse and can see what libraries are referenced by focusing the “core.full.path”

    Here is the list of items in it:

      - /home/slorber/workspace/core/lib/server/commons-logging-1.1.jar - /home/slorber/workspace/core/lib/server/mysql-connector-java-5.1.7- bin.jar - /home/slorber/workspace/core/lib/build/commons-codec-1.3.jar - /home/slorber/workspace/core/lib/build/commons-httpclient-3.1.jar - /home/slorber/workspace/core/lib/build/ejb-api-3.0.jar - /home/slorber/workspace/core/lib/build/el-api.jar - /home/slorber/workspace/core/lib/build/el-ri.jar - /home/slorber/workspace/core/lib/build/freemarker.jar - /home/slorber/workspace/core/lib/build/glassfish-persistence-api- b32g.jar - /home/slorber/workspace/core/lib/build/hibernate-tools.jar - /home/slorber/workspace/core/lib/build/javaee.jar - /home/slorber/workspace/core/lib/build/javax.servlet.jar - /home/slorber/workspace/core/lib/build/jaxen-1.1.1.jar - /home/slorber/workspace/core/lib/build/jms.jar - /home/slorber/workspace/core/lib/build/jsf-api-1.2.jar - /home/slorber/workspace/core/lib/build/jsf-impl-1.2.jar - /home/slorber/workspace/core/lib/build/jstl.jar - /home/slorber/workspace/core/lib/build/junit-4.5.jar - /home/slorber/workspace/core/lib/build/mail-1.4.1.jar - /home/slorber/workspace/core/lib/build/myfaces-api-1.1.5.jar - /home/slorber/workspace/core/lib/build/myfaces-impl-1.1.5.jar - /home/slorber/workspace/core/lib/build/pmd-4.2.5.jar - /home/slorber/workspace/core/lib/build/reportng-0.9.8.jar - /home/slorber/workspace/core/lib/build/servlet-api.jar - /home/slorber/workspace/core/lib/build/standard.jar - /home/slorber/workspace/core/lib/build/testng-jdk15.jar - /home/slorber/workspace/core/lib/build/velocity-dep-1.4.jar - /home/slorber/workspace/core/lib/runtime/antlr-2.7.6.jar - /home/slorber/workspace/core/lib/runtime/asm.jar - /home/slorber/workspace/core/lib/runtime/axis-ant.jar - /home/slorber/workspace/core/lib/runtime/axis.jar - /home/slorber/workspace/core/lib/runtime/commons-beanutils-1.8.0.jar - /home/slorber/workspace/core/lib/runtime/commons-collections-3.1.jar - /home/slorber/workspace/core/lib/runtime/commons-dbcp-all-1.3- r699049.jar - /home/slorber/workspace/core/lib/runtime/commons-discovery-0.2.jar - /home/slorber/workspace/core/lib/runtime/commons-fileupload-1.2.1.jar - /home/slorber/workspace/core/lib/runtime/commons-httpclient-3.1.jar - /home/slorber/workspace/core/lib/runtime/commons-io-1.4.jar - /home/slorber/workspace/core/lib/runtime/commons-lang-2.3.jar - /home/slorber/workspace/core/lib/runtime/dom4j-1.6.1.jar - /home/slorber/workspace/core/lib/runtime/ehcache-1.2.3.jar - /home/slorber/workspace/core/lib/runtime/ejb3-persistence.jar - /home/slorber/workspace/core/lib/runtime/hibernate- annotations-3.4.0.ga.jar - /home/slorber/workspace/core/lib/runtime/hibernate-cglib- repack-2.1_3.jar - /home/slorber/workspace/core/lib/runtime/hibernate-commons- annotations-3.4.0.jar - /home/slorber/workspace/core/lib/runtime/hibernate-core-3.3.1.GA.jar - /home/slorber/workspace/core/lib/runtime/hibernate- entitymanager-3.4.0.ga.jar - /home/slorber/workspace/core/lib/runtime/javassist-3.4.GA.jar - /home/slorber/workspace/core/lib/runtime/jaxrpc.jar - /home/slorber/workspace/core/lib/runtime/jdom.jar - /home/slorber/workspace/core/lib/runtime/jta-1.1.jar - /home/slorber/workspace/core/lib/runtime/log4j-1.2.14.jar - /home/slorber/workspace/core/lib/runtime/quartz-all-1.6.4.jar - /home/slorber/workspace/core/lib/runtime/saaj.jar - /home/slorber/workspace/core/lib/runtime/slf4j-api-1.5.5.jar - /home/slorber/workspace/core/lib/runtime/slf4j-jdk14-1.5.5.jar - /home/slorber/workspace/core/lib/runtime/spring-2.0.4.jar - /home/slorber/workspace/core/lib/runtime/wsdl4j-1.5.1.jar

    I can see into hibernate-core-3.3.1.GA.jar that there is /org/hibernate/cfg/Configuration.class

    So if you have any idea about this problem… :wink: thank you

Btw i noticed in the documentation about the “classpathref”:
“A reference to the classpath that contains the database driver, liquibase.jar, and the changelog.xml file [required]”
(http://www.liquibase.org/manual/diffdatabasetochangelog_ant_task)

I suppose my hibernate jars can’t be included like that…
I tried to import them to the classpath while running ant, and seems to work (but another error appears ^^). Is there a way to give the hibernate .jars in Ant directly without having to configure it in Eclipse Ant classpath?

Btw can someone explain me the difference between the base and target DB ? with hibernate i shoult put my real db in base or target?

I’ve got something like that:

driver="${db.driver}"
url="${db.url}"
username="${db.user}"
password="${db.pass}"
   
baseUrl=“hibernate:/home/slorber/workspace/core/etc/META-INF/persistence.xml”
baseUsername="${db.user}"
basePassword="${db.pass}"

don’t really know what should i use as login / pass / driver for the hibernate part…

My new error is:

    BUILD FAILED /home/slorber/workspace/build-xxx/build.xml:875: liquibase.exception.JDBCException: org.hibernate.HibernateException: /home/slorber/workspace/core/etc/META-INF/persistence.xml not found at liquibase.ant.DiffDatabaseTask.execute(DiffDatabaseTask.java:97) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329) at org.apache.tools.ant.Project.executeTarget(Project.java:1298) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.apache.tools.ant.Project.executeTargets(Project.java:1181) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) Caused by: liquibase.exception.JDBCException: org.hibernate.HibernateException: /home/slorber/workspace/core/etc/META-INF/persistence.xml not found at liquibase.database.structure.HibernateDatabaseSnapshot.(HibernateDatabaseSnapshot.java:189) at liquibase.database.HibernateDatabase.createDatabaseSnapshot(HibernateDatabase.java:31) at liquibase.diff.Diff.compare(Diff.java:62) at liquibase.ant.DiffDatabaseTask.execute(DiffDatabaseTask.java:88) ... 15 more Caused by: org.hibernate.HibernateException: /home/slorber/workspace/core/etc/META-INF/persistence.xml not found at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170) at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1439) at org.hibernate.cfg.Configuration.configure(Configuration.java:1461) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64) at liquibase.database.structure.HibernateDatabaseSnapshot.(HibernateDatabaseSnapshot.java:43) ... 18 more --- Nested Exception --- liquibase.exception.JDBCException: org.hibernate.HibernateException: /home/slorber/workspace/core/etc/META-INF/persistence.xml not found at liquibase.database.structure.HibernateDatabaseSnapshot.(HibernateDatabaseSnapshot.java:189) at liquibase.database.HibernateDatabase.createDatabaseSnapshot(HibernateDatabase.java:31) at liquibase.diff.Diff.compare(Diff.java:62) at liquibase.ant.DiffDatabaseTask.execute(DiffDatabaseTask.java:88) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329) at org.apache.tools.ant.Project.executeTarget(Project.java:1298) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.apache.tools.ant.Project.executeTargets(Project.java:1181) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) Caused by: org.hibernate.HibernateException: /home/slorber/workspace/core/etc/META-INF/persistence.xml not found at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170) at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1439) at org.hibernate.cfg.Configuration.configure(Configuration.java:1461) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64) at liquibase.database.structure.HibernateDatabaseSnapshot.(HibernateDatabaseSnapshot.java:43) ... 18 more

I can tell that this persistence.xml file exist and it’s the good path :slight_smile:

Even though it says NoClassDefFoundError: org/hibernate/cfg/Configuration, it could be a class that Configuration references, or that it loads dynamically (like your configured jdbc driver).  You should be able to specify the classpath containing hibernate and all its required jars with the classpathref attribute like you have.

I always forget the difference between base and target database.  We are going to rename them in liquibase 2.0 to something better.  I usually just try them in one order, then the other and see which is right :slight_smile:

Does your new error go away if you specify the xml file as classpath relative? hibernate:META-INF/persistence.xml ?

Nathan

Originally posted by: Nathan
Even though it says NoClassDefFoundError: org/hibernate/cfg/Configuration, it could be a class that Configuration references, or that it loads dynamically (like your configured jdbc driver).  You should be able to specify the classpath containing hibernate and all its required jars with the classpathref attribute like you have.

Seems it doesn’t work, i tried with the exact same libraries, added by classpathref, and added by eclipse ant plugin’s classpath.

It only works in the 2nd case for me…
Same for the persistence.xml, added by classpathref -> i can see it in the list but hibernate can’t find the file with relative path.
With absolute path it’s the same, i guess it’s an hibernate issue.

Now i tried to add the persistence.xml in the ant classpath and… it has been found :smiley:

But… I have a new error  ;D

BUILD FAILED /home/slorber/workspace/build-xxx/build.xml:880: liquibase.exception.JDBCException: org.hibernate.MappingException: invalid configuration at liquibase.ant.DiffDatabaseTask.execute(DiffDatabaseTask.java:97) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329) at org.apache.tools.ant.Project.executeTarget(Project.java:1298) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.apache.tools.ant.Project.executeTargets(Project.java:1181) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) Caused by: liquibase.exception.JDBCException: org.hibernate.MappingException: invalid configuration at liquibase.database.structure.HibernateDatabaseSnapshot.(HibernateDatabaseSnapshot.java:189) at liquibase.database.HibernateDatabase.createDatabaseSnapshot(HibernateDatabase.java:31) at liquibase.diff.Diff.compare(Diff.java:62) at liquibase.ant.DiffDatabaseTask.execute(DiffDatabaseTask.java:88) ... 15 more Caused by: org.hibernate.MappingException: invalid configuration at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1521) at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1035) at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64) at org.hibernate.cfg.Configuration.configure(Configuration.java:1462) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64) at liquibase.database.structure.HibernateDatabaseSnapshot.(HibernateDatabaseSnapshot.java:43) ... 18 more Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:250) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3095) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:921) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) at org.dom4j.io.SAXReader.read(SAXReader.java:465) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518) ... 24 more --- Nested Exception --- liquibase.exception.JDBCException: org.hibernate.MappingException: invalid configuration at liquibase.database.structure.HibernateDatabaseSnapshot.(HibernateDatabaseSnapshot.java:189) at liquibase.database.HibernateDatabase.createDatabaseSnapshot(HibernateDatabase.java:31) at liquibase.diff.Diff.compare(Diff.java:62) at liquibase.ant.DiffDatabaseTask.execute(DiffDatabaseTask.java:88) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329) at org.apache.tools.ant.Project.executeTarget(Project.java:1298) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.apache.tools.ant.Project.executeTargets(Project.java:1181) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) Caused by: org.hibernate.MappingException: invalid configuration at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1521) at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1035) at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64) at org.hibernate.cfg.Configuration.configure(Configuration.java:1462) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64) at liquibase.database.structure.HibernateDatabaseSnapshot.(HibernateDatabaseSnapshot.java:43) ... 18 more Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:250) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3095) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:921) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) at org.dom4j.io.SAXReader.read(SAXReader.java:465) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518) ... 24 more

Just to know, in EJB3 context, we should use persistence.xml? Or shall we create a standard hibernate hbm file?

Ok so after reading one of your comments on stackoverflow it seems we have to create a hibernate hbm file in addition to the persistence.xml :slight_smile:

It would be really great in a future version to have a new feature that can take persistence.xml :wink:

Finally got my first changelog :smiley:

Actually i ask myself something: which value to put for hibernate.hbm2ddl.auto on the hibernate config file? Does it change something?

I tried with both create/update and got the same changeLog

My db is structured like that:

  • I have the db schema based on JPA/Hibernate mapping
  • I have some history tables
  • I have some jobs tables (Quartz)

My actual db is up to date with the JPA mapping.

On the changelog i get the following:

  • Drop of history and job tables (no mapping with hibernate for these). I assume it can’t be handled manually and that we have to delete manually these lines of the changelog
    ...              ...
  • Many add/drop constraints/indexes
    ...                                                                                                             ...                                                 ...                 ...                 ...

Since my base is up to date with my mapping, shouldn’t i get in changelog only the drop on unmapped tables?

Then why i get so many drop/add index/constraints?

And most surprising for me: look at the last changelog sample, liquibase seems to drop and then add the exact same constraint / index (or add and then drop, don’t know yet in which order changesets are executed ^^).

Also wonder which are the “best practices” that i should use with liquibase. Should i first create a new database and generate the first changelog with the full database creation?
I suppose my quartz / history tables + triggers should be added manually in that changelog then no?

Thank you for helping me,
S�bastien Lorber.

Support for persistence.xml is something we would like to add, it is just somethign we haven’t gotten to yet.  Also, the logic we use for identifying foreign keys, indexes, and constraints is in need of improvement.  It is something we are working on for liquibase 2.0.

The way I envision the liquibase/hibernate working is a replacement for hbm2ddl.auto.  You would make the changes to your hibernate mapping/objects then run generateChangeLog and it will append what has changed to your changelog file.  You would then inspect it and modify it as needed (convert “drop table/add table” to “rename table” etc) then run your changelog against the database.

We haven’t handled the case of unmanaged tables, but we should add support for specifying tables to ignore in the diff command.

Nathan

Thanks for answering :wink:

Actually it will be complicated for me to use liquibase, will stay with hbm2ddl for the moment :’(

But will see when 2.0 is out :wink:

I still wonder how to use this tool correctly…

What should we do to changelog files? Should we put all these on svn? Or merge all changelogs into one big changelog that trace the full changes of the db? Should we  include eventually in this big changelog the full database creation from the very beginning? …

Have you recommendations on the way to use it on a long term common usecase, with Hibernate and dev team? (not only for just one migration i mean).

Thanks

To Nathan:
I’ve seen that the release candidate for Liquibase 2.0 is out.
Does it support the usage of persistence.xml now?
If so how should one define the baseUrl in that case?

Unfortunately, I had to push the improved hibernate diff support out to 2.1.  There go to be too much stuff for 2.0 and something had to go, and that included the enhancements to diff (including the hibernate diffs).

I wanted to make sure 2.0 got out in a timely manner and prioritized releasing sooner over having all planned features.  I’m hoping to get back to a 1-2 month release cycle after 2.0 is released, so 2.1 will probably be beginning of december (+/- a month)

Nathan