Execute sql script after jpa/EclipseLink created tables?

后端 未结 6 659
一个人的身影
一个人的身影 2021-01-01 23:24

is there a possibility to execute an sql script, after EclipseLink generated the ddl?
In other words, is it possible that the EclipseLink property \"eclipselink.ddl-gene

6条回答
  •  迷失自我
    2021-01-02 00:02

    I came across this question for the same reasons, trying to find an approach to run an initialization script after DDL generation. I offer this answer to an old question in hopes of shortening the amount of "literary research" for those looking for the same solution.

    I'm using GlassFish 4 with its default EclipseLink 2.5 JPA implementation. The new Schema Generation feature under JPA 2.1 makes it fairly straightforward to specify an "initialization" script after DDL generation is completed.

    
    
        
            org.eclipse.persistence.jpa.PersistenceProvider
            java:app/jdbc/cbesPool
            
                
                
                
                
                 
            
        
    
    

    The above configuration generates DDL scripts from metadata (i.e. annotations) after which the META-INF/sql/load_script.sql script is run to populate the database. In my case, I seed a few tables with test data and generate additional views.

    Additional information on EclipseLink's use of JPA's properties can be found in the DDL Generation section of EclipseLink/Release/2.5/JPA21. Likewise, Section 37.5 Database Schema Creation in Oracle's Java EE 7 Tutorial and TOTD #187 offer a quick introduction also.

提交回复
热议问题