liquibase:diff not giving me expected result

后端 未结 1 1217
醉酒成梦
醉酒成梦 2021-01-17 04:28

I have a JPA entity called customer and goes like this

@Entity
public class Customer {



private int custNo;
private String custName;
private          


        
1条回答
  •  粉色の甜心
    2021-01-17 05:25

    I used the liquibase-hibernate plugin for this!. It is capable of generating the changeset for a JPA entity even if its corresponding table is not there in the db.

    The plugin

    
        
            org.liquibase
            liquibase-maven-plugin
            3.4.1
                              
                src/main/resources/liquibase.properties
             
            
                
                    org.liquibase.ext
                    liquibase-hibernate4
                    3.5
                
                
                    org.springframework
                    spring-beans
                    4.1.7.RELEASE
                
                
                    org.springframework.data
                    spring-data-jpa
                    1.7.3.RELEASE
                
                           
         
    
    

    and the liquibase.properties

    changeLogFile=classpath:liquibase-changeLog.xml
    url=jdbc:mysql://localhost:3306/oauth_reddit
    username=tutorialuser
    password=tutorialmy5ql
    driver=com.mysql.jdbc.Driver
    referenceUrl=hibernate:spring:org.baeldung.persistence.model
      ?dialect=org.hibernate.dialect.MySQLDialect
    diffChangeLogFile=src/main/resources/liquibase-diff-changeLog.xml
    

    The referenceUrl is using package scan, so the dialect parameter is required. changeLogFile is the location of changeset for which the db is in sync. diffChangeLogFile is the location where the difference changelog has to be flushed.

    0 讨论(0)
提交回复
热议问题