Here's how I solved it:
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.apache.griffin.core.config; import java.util.HashMap; import java.util.Map; import javax.sql.DataSource; import org.eclipse.persistence.config.PersistenceUnitProperties; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter; import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter; import org.springframework.transaction.jta.JtaTransactionManager; @Configuration @ComponentScan("org.apache.griffin.core") public class EclipseLinkJpaConfig extends JpaBaseConfiguration { protected EclipseLinkJpaConfig( DataSource ds, JpaProperties properties, ObjectProvider<JtaTransactionManager> jtm, ObjectProvider<TransactionManagerCustomizers> tmc) { super(ds, properties, jtm, tmc); } @Override protected AbstractJpaVendorAdapter createJpaVendorAdapter() { return new EclipseLinkJpaVendorAdapter(); } @Override protected Map<String, Object> getVendorProperties() { Map<String, Object> map = new HashMap<>(); map.put(PersistenceUnitProperties.WEAVING, "false"); // Set the create policy for the table map.put(PersistenceUnitProperties.DDL_GENERATION, "none"); return map; } } I set the PersistenceUnitProperties DDL_GENERATION attribute's value to none, no error occurred On 02/25/2019 17:21,Kevin Yao<[email protected]> wrote: Hi, This is the error message given by EclipseLink not Griffin code. You may changed entity code ( service- > src -> main -> java -> org.apache.griffin.core.* -> entity) before starting. When you start Griffin, EclipseLink will automatically update database table information,such as column, constraint. For example, for the error message *Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Can't write; duplicate key in table '#sql-12c8_1bf930' *with sql* ALTER TABLE SEGMENTPREDICATE ADD CONSTRAINT FK_SEGMENTPREDICATE_data_connector_id FOREIGN KEY (data_connector_id) REFERENCES DATACONNECTOR (ID)*, the most likely there is already a constraint with *FK_SEGMENTPREDICATE_data_connector_id* in your database. Therefore, you can check your changed code find out where the problem lies. The worst solution is to delete tables and update it automatically by EclipseLink. Thanks, Kevin On Mon, Feb 25, 2019 at 3:44 PM 大鹏 <[email protected]> wrote: When I started the service, I encountered the following exception. May I ask which line of code printed this exception? I didn't find it.The exception information is as follows: Call: ALTER TABLE SEGMENTPREDICATE ADD CONSTRAINT FK_SEGMENTPREDICATE_data_connector_id FOREIGN KEY (data_connector_id) REFERENCES DATACONNECTOR (ID) Query: DataModifyQuery(sql="ALTER TABLE SEGMENTPREDICATE ADD CONSTRAINT FK_SEGMENTPREDICATE_data_connector_id FOREIGN KEY (data_connector_id) REFERENCES DATACONNECTOR (ID)") [EL Warning]: 2019-02-25 15:40:19.465--ServerSession(1872774414)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Can't write; duplicate key in table '#sql-12c8_1bf930' Error Code: 1022 Call: ALTER TABLE DATACONNECTOR ADD CONSTRAINT FK_DATACONNECTOR_data_source_id FOREIGN KEY (data_source_id) REFERENCES DATASOURCE (ID) Query: DataModifyQuery(sql="ALTER TABLE DATACONNECTOR ADD CONSTRAINT FK_DATACONNECTOR_data_source_id FOREIGN KEY (data_source_id) REFERENCES DATASOURCE (ID)") [EL Warning]: 2019-02-25 15:40:19.499--ServerSession(1872774414)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Can't write; duplicate key in table '#sql-12c8_1bf930' Error Code: 1022 Call: ALTER TABLE DATASOURCE ADD CONSTRAINT FK_DATASOURCE_measure_id FOREIGN KEY (measure_id) REFERENCES MEASURE (ID) Query: DataModifyQuery(sql="ALTER TABLE DATASOURCE ADD CONSTRAINT FK_DATASOURCE_measure_id FOREIGN KEY (measure_id) REFERENCES MEASURE (ID)") [EL Warning]: 2019-02-25 15:40:19.532--ServerSession(1872774414)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Can't write; duplicate key in table '#sql-12c8_1bf930' Error Code: 1022 Call: ALTER TABLE EXTERNALMEASURE ADD CONSTRAINT FK_EXTERNALMEASURE_VIRTUALJOB_ID FOREIGN KEY (VIRTUALJOB_ID) REFERENCES job (ID) Query: DataModifyQuery(sql="ALTER TABLE EXTERNALMEASURE ADD CONSTRAINT FK_EXTERNALMEASURE_VIRTUALJOB_ID FOREIGN KEY (VIRTUALJOB_ID) REFERENCES job (ID)") [EL Warning]: 2019-02-25 15:40:19.561--ServerSession(1872774414)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Can't write; duplicate key in table '#sql-12c8_1bf930' Error Code: 1022 Call: ALTER TABLE GRIFFINMEASURE ADD CONSTRAINT FK_GRIFFINMEASURE_ID FOREIGN KEY (ID) REFERENCES MEASURE (ID) Query: DataModifyQuery(sql="ALTER TABLE GRIFFINMEASURE ADD CONSTRAINT FK_GRIFFINMEASURE_ID FOREIGN KEY (ID) REFERENCES MEASURE (ID)") [EL Warning]: 2019-02-25 15:40:19.594--ServerSession(1872774414)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Can't write; duplicate key in table '#sql-12c8_1bf930' Error Code: 1022
