I need to generate Liquibase Changelogs for my JPA Entities. My JPA provider is Hibernate 5.
- First I need to be able to generate initial changelog for my JPA entities as they are right now (to create DB schema from scratch).
- Then I will need to update the schema accordingly (by adding new changesets to my changelogs).
For Changelog generation I would like to use CLI of Liquibase, so I have downloaded Liquibase Hibernate plugin ( GitHub - liquibase/liquibase-hibernate: Liquibase Hibernate Integration ) and I have saved the JAR file to /lib folder of Liquibase installation.
Now according to wiki I can configure the URL to use special format for Hibernate JPA.
The class MyConfigFactory should extend CustomClassicConfigurationFactory interface of Liquibase-Hibernate plugin.
I have several questions:
- From which folder should I run the Liquibase command so it will find my JPA annotated classes?
- Do these classes need to be *.java source code or compiled *.class files?
- How should I configure the plugin if I use custom strategy for table naming process? (I have custom class called PrefixedTableNamingStrategy which extends PhysicalNamingStrategyStandardImpl)
- For Hibernate configuration (e.g. to configure available annotated entities and DB credentials) I’m using Hibernate’s “Configuration” class, from which I create Session Factory. Does Liquibase support this anyhow? Or do I need to convert it to Metadata?
- How does the plugin work under the hood? Does it scan the entities and their annotations and then generate changelog? Or does it actually execute Java code? (e.g. to process the class extending CustomClassicConfigurationFactory).
- I cannot find CustomClassicConfigurationFactory interface in the Liquibase-hibernate plugin, what should I do? I’m not using hibernate.cfg.xml file, as I’m configuring Hibernate properties dynamically on the fly (e.g. adding new annotated entities and loading DB credentials from my config file or some other source).
Thanks for answers! I’m very confused, so I would appreciate any help.