I am struggling to build the JPA
annotated classes diff changesets against my database, using liquibase.
Still, I am very confused about few things.
I use the following :
liquibase.properties
#liquibase.properties
driver: org.postgresql.Driver
classpath: real_path/.m2/repository/org/postgresql/postgresql/9.2-1002-jdbc4/postgresql-9.2-1002-jdbc4.jar
url: jdbc:postgresql://localhost:5432/diquiz
username: postgres
password: postgres
referenceUrl: hibernate:ejb3:diQuiz
referenceUsername: postgres
referencePassword: postgres
changeLogFile: changelog-master.xml
and
java -jar real_path\liquibase-core-3.0.6.jar diffChangeLog
and a normal persistence.xml
file with standard JPA configuration.
I get an error which says : Liquibase diffChangeLog Failed: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:ejb3:unit)
I am confused because the below answer says that we need a hibernate.cfg.xml
file (even I have persistence.xml
instead), but then he says that we can use some url's which are defined on wiki page.
Hibernate using JPA (annotated Entities) and liquibase
Wiki page says that if we need to use JPA, we can choose between three types of URL's.
hibernate:ejb3:myPersistenceUnit
hibernate:ejb3:com.example.MyConfigFactory
hibernate:ejb3:myPersistenceUnit?hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
So, I choose the first one, and I've set in the liquidbase.properties this as referenceUrl
.
Also, on the wiki page it is mentioned : (https://github.com/liquibase/liquibase-hibernate/wiki)
If you are using the command line version of Liquibase, you simply have to add the liquibase-hibernate[3|4].jar file to the LIQUIBASE_HOME/lib directory.
I did this too. Still, doesnt work. Can someone explain me somewhow what am I missing ?
Thanks a lot!
The problem is that you are calling liquibase with "java -jar". The Class-path line in the jar can't pick up additional jars from the lib directory and so the liquibase-hibernate.jar is not being included in the classpath.
Run liquibase using the sh/bat file included in the liquibase jar: real_path/liquibase[.bat] diffChangeLog