How to work with javax.persistence.sql-load-script-source?

回眸只為那壹抹淺笑 提交于 2019-12-06 14:05:09

What version of EclipseLink are you using? These properties are part of JPA 2.1, so you must be using the EclipseLink 2.5 version (not yet released).

Enable logging on finest to see if any errors are occurring.

A more general answer adding to James is that JPA 2.1 is part of the JEE7 specification. A JEE6 (which specifies JPA 2.0) compatible application server cannot use these properties (without patching the server for JPA 2.1):

<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.create-source" value="script"/>
<property name="javax.persistence.schema-generation.create-script-source" value="META-INF/sql/create.sql" />
<property name="javax.persistence.sql-load-script-source" value="META-INF/sql/data.sql" />
<property name="javax.persistence.schema-generation.drop-source" value="script" />
<property name="javax.persistence.schema-generation.drop-script-source" value="META-INF/sql/drop.sql" />

An example of an application server implementing JEE6 is Jboss 7. Wildfly 8, however, implements JEE7 and these properties should be available for use.

A hint if you are not really sure is to observe the version attribute on the persistence tag. In this case, it is 2.0. If it is specified as 2.1, and properly configured so, JPA 2.1 is used and the properties will work.

I think the problem is in the value of the property. You must set the location in relation to the src. Something like this:

<properties>
  <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
  <property name="javax.persistence.ddl-drop-script-source" value="main/resources/drop.sql" />
  <property name="javax.persistence.sql-load-script-source" value="main/resources/insert.sql"/>
</properties>

I recommend you visit this link for more information about Database Schema Creation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!