diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/reservedwords/ReservedWordsIT.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/reservedwords/ReservedWordsIT.java index 90b300dcb..6effbdfac 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/reservedwords/ReservedWordsIT.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/reservedwords/ReservedWordsIT.java @@ -27,6 +27,7 @@ import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase; import javax.persistence.EntityManager; import javax.persistence.Query; import java.io.*; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -83,14 +84,30 @@ public class ReservedWordsIT extends AbstractPersistenceTestCase { Log log = getLog(); try (OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("target/reserved_words_" + - dict.getClass().getSimpleName() + ".properties"))) { - String msg = "# FOUND " + reservedColumnWords.size() + " RESERVED WORDS for Dictionary " + dict.getClass().getName(); - log.info(msg); - osw.append(msg).append('\n'); + dict.getClass().getSimpleName() + ".java"))) { + log.info("FOUND " + reservedColumnWords.size() + " RESERVED WORDS for Dictionary " + dict.getClass().getName()); + osw.append( + "// reservedWordSet subset that CANNOT be used as valid column names\n" + + "// (i.e., without surrounding them with double-quotes)\n" + + "// generated at " + LocalDateTime.now() + " via " + ReservedWordsIT.class.getName() + "\n" + + "invalidColumnWordSet.addAll(Arrays.asList(new String[] {\n"); + StringBuilder sb = new StringBuilder(); + sb.append(" "); for (String reservedColumnWord : reservedColumnWords) { log.info(reservedColumnWord); - osw.append(reservedColumnWord).append('\n'); + sb.append('"').append(reservedColumnWord).append("\", "); + if (sb.length() > 110) { + osw.append(sb.toString().trim()).append('\n'); + sb.setLength(0); + } } + + // also add the rest if any + if (sb.length() > 0) { + osw.append(sb.toString().trim()).append('\n'); + } + + osw.append("}));"); osw.flush(); } log.info("******* END RESERVED WORDS *******"); diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/reservedwords/sql_reserved_words.txt b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/reservedwords/sql_reserved_words.txt index 487e0ffac..0504b780d 100644 --- a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/reservedwords/sql_reserved_words.txt +++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/reservedwords/sql_reserved_words.txt @@ -296,6 +296,7 @@ G GENERAL GENERATED GET +GETCURRENTCONNECTION GLOBAL GO GOTO @@ -411,6 +412,7 @@ LONGTEXT LOOP LOW_PRIORITY LOWER +LTRIM M MAP MATCH @@ -484,6 +486,7 @@ NULLIF NULLS NUMBER NUMERIC +NVARCHAR OBJECT OCTET_LENGTH OCTETS @@ -633,6 +636,8 @@ ROWGUIDCOL ROWID ROWNUM ROWS +ROW_NUMBER +RTRIM RULE SAVE SAVEPOINT @@ -719,6 +724,7 @@ STYLE SUBCLASS_ORIGIN SUBLIST SUBMULTISET +SUBSTR SUBSTRING SUCCESSFUL SUM @@ -838,6 +844,11 @@ WORK WRITE WRITETEXT X509 +XML +XMLEXISTS +XMLPARSE +XMLQUERY +XMLSERIALIZE XOR YEAR YEAR_MONTH