通过eclipseLink生成sql的问题 - 缺少分隔符 [英] Problems with generating sql via eclipseLink - missing separator

查看:172
本文介绍了通过eclipseLink生成sql的问题 - 缺少分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eclipseLink和jpa。在我的persistence.xml中
,我定义为生成一个create.sql文件。将生成该文件,但缺少';' - 每个sql语句的分隔符。



是否有可能在persistence.xml或某些文件中定义分隔符其他方式?



示例persistence.xml:

 < provider> ; org.eclipse.persistence.jpa.PersistenceProvider< /提供商GT; 

< exclude-unlisted-classes> false< / exclude-unlisted-classes>

< class> de.company.project.models.User< / class>

< properties>
< property name =eclipselink.ddl-generationvalue =drop-and-create-tables/>
< property name =eclipselink.application-locationvalue =/ sql/>
< property name =eclipselink.create-ddl-jdbc-file-namevalue =create.sql/>
< property name =eclipselink.drop-ddl-jdbc-file-namevalue =drop.sql/>
< property name =eclipselink.ddl-generation.output-modevalue =sql-script/>
< / properties>

示例生成的sql文件:

  CREATE TABLE app_user(
ID INTEGER NOT NULL,
last_name VARCHAR(50)NOT NULL,
username VARCHAR(15)NOT NULL,
user_password VARCHAR(50)NOT NULL,
first_name VARCHAR(50)NOT NULL,
PRIMARY KEY(ID))

CREATE TABLE SEQUENCE(
SEQ_NAME VARCHAR(50) NOT NULL,
SEQ_COUNT DECIMAL(38),
PRIMARY KEY(SEQ_NAME))

INSERT INTO SEQUENCE(SEQ_NAME,SEQ_COUNT)
values('SEQ_GEN_TABLE',0 )


解决方案

我遇到了这个问题并通过设置persistence.xml中的属性。



自Eclipselink 2.6以来,有一个属性eclipselink.ddlgen-terminate-statements,当设置为true时,将附加一个分隔符每个陈述。



我认为我当时正在使用H2数据库。



有关详细信息,请参阅< a href =http:// www.eclipse.org/eclipselink/api/2.6/org/eclipse/persistence/config/PersistenceUnitProperties.htmlrel =nofollow noreferrer> http://www.eclipse.org/eclipselink/api/2.6/org/eclipse /persistence/config/PersistenceUnitProperties.html


i'am using eclipseLink with jpa. in my persistence.xml, i defined to generate a create.sql file. the file will be generated, but with missing ';'-separators for each sql statement.

is there a possibility to define a separator in the persistence.xml or in some other way?

Example persistence.xml:

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

<exclude-unlisted-classes>false</exclude-unlisted-classes>

<class>de.company.project.models.User</class>

<properties>
      <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
      <property name="eclipselink.application-location" value="/sql" />
      <property name="eclipselink.create-ddl-jdbc-file-name" value="create.sql"/>
      <property name="eclipselink.drop-ddl-jdbc-file-name" value="drop.sql"/>
      <property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
</properties>

Example generated sql file:

CREATE TABLE app_user (
ID INTEGER NOT NULL, 
last_name VARCHAR(50) NOT NULL,         
username    VARCHAR(15) NOT NULL, 
user_password VARCHAR(50) NOT NULL, 
first_name  VARCHAR(50) NOT NULL, 
PRIMARY KEY (ID))

CREATE TABLE SEQUENCE (
 SEQ_NAME VARCHAR(50) NOT NULL,
 SEQ_COUNT DECIMAL(38), 
 PRIMARY  KEY (SEQ_NAME))

INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) 
values ('SEQ_GEN_TABLE', 0)

解决方案

I encountered this problem and solved it by setting a property in persistence.xml.

Since Eclipselink 2.6, there is a property "eclipselink.ddlgen-terminate-statements" that when set to true, a delimiter will be appended to each statement.

I think I was using H2 database at that time.

For more details, see http://www.eclipse.org/eclipselink/api/2.6/org/eclipse/persistence/config/PersistenceUnitProperties.html

这篇关于通过eclipseLink生成sql的问题 - 缺少分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆