This is important to note... The Reserved Word checking on modello-plugin-jpox is much more strict now.
This applies to modello 1.0-alpha-15-SNAPSHOT When performing a jpox-jdo-mapping call on modello-maven-plugin, you will now see much more clear error messages when working with models that could violate a reserved word check against table names and/or column names. These violations will point out the way to change the table / column names on the DB side to no longer violate the reserved word check. Please be aware of it. - Joakim [EMAIL PROTECTED] wrote: > > Revision > 820 <http://fisheye.codehaus.org/changelog/modello/?cs=820> > Author > joakime > Date > 2007-03-13 09:05:19 -0500 (Tue, 13 Mar 2007) > > > Log Message > > * Moving from internal DBKeywords to new modello-db-keywords project. > * Making reserved word violations much more strict. > * Correcting test.mdo model to not violate reserved words on any DB. > > > Modified Paths > > * trunk/modello-plugins/modello-plugin-jpox/pom.xml > <#trunkmodellopluginsmodellopluginjpoxpomxml> > * > trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGenerator.java > > <#trunkmodellopluginsmodellopluginjpoxsrcmainjavaorgcodehausmodellopluginjpoxJPoxJdoMappingModelloGeneratorjava> > * > trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml > > <#trunkmodellopluginsmodellopluginjpoxsrcmainresourcesMETAINFplexuscomponentsxml> > * trunk/modello-plugins/modello-plugin-jpox/src/test/resources/test.mdo > <#trunkmodellopluginsmodellopluginjpoxsrctestresourcestestmdo> > > > Removed Paths > > * > trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/DBKeywords.java > > <#trunkmodellopluginsmodellopluginjpoxsrcmainjavaorgcodehausmodellopluginjpoxDBKeywordsjava> > > > Diff > > > Modified: trunk/modello-plugins/modello-plugin-jpox/pom.xml > (819 => 820) > > --- trunk/modello-plugins/modello-plugin-jpox/pom.xml 2007-03-12 17:18:51 UTC > (rev 819) > +++ trunk/modello-plugins/modello-plugin-jpox/pom.xml 2007-03-13 14:05:19 UTC > (rev 820) > @@ -14,6 +14,11 @@ > <artifactId>modello-plugin-store</artifactId> > </dependency> > <dependency> > + <groupId>org.codehaus.modello</groupId> > + <artifactId>modello-db-keywords</artifactId> > + <version>1.0-SNAPSHOT</version> > + </dependency> > + <dependency> > <groupId>dom4j</groupId> > <artifactId>dom4j</artifactId> > <version>1.6.1</version> > > > Deleted: > > trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/DBKeywords.java > (819 => 820) > > --- > trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/DBKeywords.java > 2007-03-12 17:18:51 UTC (rev 819) > +++ > trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/DBKeywords.java > 2007-03-13 14:05:19 UTC (rev 820) > @@ -1,264 +0,0 @@ > -package org.codehaus.modello.plugin.jpox; > - > -/* > - * Copyright 2001-2006 The Apache Software Foundation. > - * > - * Licensed 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. > - */ > - > -import org.codehaus.plexus.util.StringUtils; > - > -import java.util.ArrayList; > -import java.util.List; > - > -/** > - * DBKeywords, checks against the SQL92 Reserved Word List. > - * > - * TODO: Need to ensure that SQL99 and SQL2003 are also covered - > http://developer.mimer.se/validator/sql-reserved-words.tml > - * > - * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a> > - * @version $Id$ > - */ > -public class DBKeywords > -{ > - private static final List sql92reserved; > - > - public static final String URL_SQL92 = > "http://db.apache.org/derby/docs/10.1/ref/rrefkeywords29722.html"; > - > - static > - { > - List reserved = new ArrayList(); > - > - reserved.add( "ADD" ); > - reserved.add( "ALL" ); > - reserved.add( "ALLOCATE" ); > - reserved.add( "ALTER" ); > - reserved.add( "AND" ); > - reserved.add( "ANY" ); > - reserved.add( "ARE" ); > - reserved.add( "AS" ); > - reserved.add( "ASC" ); > - reserved.add( "ASSERTION" ); > - reserved.add( "AT" ); > - reserved.add( "AUTHORIZATION" ); > - reserved.add( "AVG" ); > - reserved.add( "BEGIN" ); > - reserved.add( "BETWEEN" ); > - reserved.add( "BIT" ); > - reserved.add( "BOOLEAN" ); > - reserved.add( "BOTH" ); > - reserved.add( "BY" ); > - reserved.add( "CALL" ); > - reserved.add( "CASCADE" ); > - reserved.add( "CASCADED" ); > - reserved.add( "CASE" ); > - reserved.add( "CAST" ); > - reserved.add( "CHAR" ); > - reserved.add( "CHARACTER" ); > - reserved.add( "CHECK" ); > - reserved.add( "CLOSE" ); > - reserved.add( "COLLATE" ); > - reserved.add( "COLLATION" ); > - reserved.add( "COLUMN" ); > - reserved.add( "COMMIT" ); > - reserved.add( "CONNECT" ); > - reserved.add( "CONNECTION" ); > - reserved.add( "CONSTRAINT" ); > - reserved.add( "CONSTRAINTS" ); > - reserved.add( "CONTINUE" ); > - reserved.add( "CONVERT" ); > - reserved.add( "CORRESPONDING" ); > - reserved.add( "COUNT" ); > - reserved.add( "CREATE" ); > - reserved.add( "CURRENT" ); > - reserved.add( "CURRENT_DATE" ); > - reserved.add( "CURRENT_TIME" ); > - reserved.add( "CURRENT_TIMESTAMP" ); > - reserved.add( "CURRENT_USER" ); > - reserved.add( "CURSOR" ); > - reserved.add( "DEALLOCATE" ); > - reserved.add( "DEC" ); > - reserved.add( "DECIMAL" ); > - reserved.add( "DECLARE" ); > - reserved.add( "DEFERRABLE" ); > - reserved.add( "DEFERRED" ); > - reserved.add( "DELETE" ); > - reserved.add( "DESC" ); > - reserved.add( "DESCRIBE" ); > - reserved.add( "DIAGNOSTICS" ); > - reserved.add( "DISCONNECT" ); > - reserved.add( "DISTINCT" ); > - reserved.add( "DOUBLE" ); > - reserved.add( "DROP" ); > - reserved.add( "ELSE" ); > - reserved.add( "END" ); > - reserved.add( "ENDEXEC" ); > - reserved.add( "ESCAPE" ); > - reserved.add( "EXCEPT" ); > - reserved.add( "EXCEPTION" ); > - reserved.add( "EXEC" ); > - reserved.add( "EXECUTE" ); > - reserved.add( "EXISTS" ); > - reserved.add( "EXPLAIN" ); > - reserved.add( "EXTERNAL" ); > - reserved.add( "FALSE" ); > - reserved.add( "FETCH" ); > - reserved.add( "FIRST" ); > - reserved.add( "FLOAT" ); > - reserved.add( "FOR" ); > - reserved.add( "FOREIGN" ); > - reserved.add( "FOUND" ); > - reserved.add( "FROM" ); > - reserved.add( "FULL" ); > - reserved.add( "FUNCTION" ); > - reserved.add( "GET" ); > - reserved.add( "GET_CURRENT_CONNECTION" ); > - reserved.add( "GLOBAL" ); > - reserved.add( "GO" ); > - reserved.add( "GOTO" ); > - reserved.add( "GRANT" ); > - reserved.add( "GROUP" ); > - reserved.add( "HAVING" ); > - reserved.add( "HOUR" ); > - reserved.add( "IDENTITY" ); > - reserved.add( "IMMEDIATE" ); > - reserved.add( "IN" ); > - reserved.add( "INDICATOR" ); > - reserved.add( "INITIALLY" ); > - reserved.add( "INNER" ); > - reserved.add( "INOUT" ); > - reserved.add( "INPUT" ); > - reserved.add( "INSENSITIVE" ); > - reserved.add( "INSERT" ); > - reserved.add( "INT" ); > - reserved.add( "INTEGER" ); > - reserved.add( "INTERSECT" ); > - reserved.add( "INTO" ); > - reserved.add( "IS" ); > - reserved.add( "ISOLATION" ); > - reserved.add( "JOIN" ); > - reserved.add( "KEY" ); > - reserved.add( "LAST" ); > - reserved.add( "LEFT" ); > - reserved.add( "LIKE" ); > - reserved.add( "LONGINT" ); > - reserved.add( "LOWER" ); > - reserved.add( "LTRIM" ); > - reserved.add( "MATCH" ); > - reserved.add( "MAX" ); > - reserved.add( "MIN" ); > - reserved.add( "MINUTE" ); > - reserved.add( "NATIONAL" ); > - reserved.add( "NATURAL" ); > - reserved.add( "NCHAR" ); > - reserved.add( "NVARCHAR" ); > - reserved.add( "NEXT" ); > - reserved.add( "NO" ); > - reserved.add( "NOT" ); > - reserved.add( "NULL" ); > - reserved.add( "NULLIF" ); > - reserved.add( "NUMERIC" ); > - reserved.add( "OF" ); > - reserved.add( "ON" ); > - reserved.add( "ONLY" ); > - reserved.add( "OPEN" ); > - reserved.add( "OPTION" ); > - reserved.add( "OR" ); > - reserved.add( "ORDER" ); > - reserved.add( "OUT" ); > - reserved.add( "OUTER" ); > - reserved.add( "OUTPUT" ); > - reserved.add( "OVERLAPS" ); > - reserved.add( "PAD" ); > - reserved.add( "PARTIAL" ); > - reserved.add( "PREPARE" ); > - reserved.add( "PRESERVE" ); > - reserved.add( "PRIMARY" ); > - reserved.add( "PRIOR" ); > - reserved.add( "PRIVILEGES" ); > - reserved.add( "PROCEDURE" ); > - reserved.add( "PUBLIC" ); > - reserved.add( "READ" ); > - reserved.add( "REAL" ); > - reserved.add( "REFERENCES" ); > - reserved.add( "RELATIVE" ); > - reserved.add( "RESTRICT" ); > - reserved.add( "REVOKE" ); > - reserved.add( "RIGHT" ); > - reserved.add( "ROLLBACK" ); > - reserved.add( "ROWS" ); > - reserved.add( "RTRIM" ); > - reserved.add( "SCHEMA" ); > - reserved.add( "SCROLL" ); > - reserved.add( "SECOND" ); > - reserved.add( "SELECT" ); > - reserved.add( "SESSION_USER" ); > - reserved.add( "SET" ); > - reserved.add( "SMALLINT" ); > - reserved.add( "SOME" ); > - reserved.add( "SPACE" ); > - reserved.add( "SQL" ); > - reserved.add( "SQLCODE" ); > - reserved.add( "SQLERROR" ); > - reserved.add( "SQLSTATE" ); > - reserved.add( "SUBSTR" ); > - reserved.add( "SUBSTRING" ); > - reserved.add( "SUM" ); > - reserved.add( "SYSTEM_USER" ); > - reserved.add( "TABLE" ); > - reserved.add( "TEMPORARY" ); > - reserved.add( "TIMEZONE_HOUR" ); > - reserved.add( "TIMEZONE_MINUTE" ); > - reserved.add( "TO" ); > - reserved.add( "TRAILING" ); > - reserved.add( "TRANSACTION" ); > - reserved.add( "TRANSLATE" ); > - reserved.add( "TRANSLATION" ); > - reserved.add( "TRUE" ); > - reserved.add( "UNION" ); > - reserved.add( "UNIQUE" ); > - reserved.add( "UNKNOWN" ); > - reserved.add( "UPDATE" ); > - reserved.add( "UPPER" ); > - reserved.add( "USER" ); > - reserved.add( "USING" ); > - reserved.add( "VALUES" ); > - reserved.add( "VARCHAR" ); > - reserved.add( "VARYING" ); > - reserved.add( "VIEW" ); > - reserved.add( "WHENEVER" ); > - reserved.add( "WHERE" ); > - reserved.add( "WITH" ); > - reserved.add( "WORK" ); > - reserved.add( "WRITE" ); > - reserved.add( "XML" ); > - reserved.add( "XMLEXISTS" ); > - reserved.add( "XMLPARSE" ); > - reserved.add( "XMLSERIALIZE" ); > - reserved.add( "YEAR" ); > - > - sql92reserved = reserved; > - } > - > - public static boolean isReserved( String tst ) > - { > - if ( StringUtils.isEmpty( tst ) ) > - { > - return false; > - } > - > - // TODO: Should we include Database Implementation Specific keywords? > - > - return sql92reserved.contains( tst.trim().toUpperCase() ); > - } > -} > \ No newline at end of file > > > Modified: > > trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGenerator.java > (819 => 820) > > --- > trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGenerator.java > 2007-03-12 17:18:51 UTC (rev 819) > +++ > trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGenerator.java > 2007-03-13 14:05:19 UTC (rev 820) > @@ -24,6 +24,7 @@ > > import org.codehaus.modello.ModelloException; > import org.codehaus.modello.ModelloParameterConstants; > +import org.codehaus.modello.db.SQLReservedWords; > import org.codehaus.modello.model.Model; > import org.codehaus.modello.model.ModelAssociation; > import org.codehaus.modello.model.ModelClass; > @@ -54,6 +55,8 @@ > /** > * @author <a href="mailto:[EMAIL PROTECTED]">Trygve Laugstøl</a> > * @version $Id$ > + * @plexus.component role="org.codehaus.modello.plugin.ModelloGenerator" > + * role-hint="jpox-jdo-mapping" > */ > public class JPoxJdoMappingModelloGenerator > extends AbstractModelloGenerator > @@ -63,6 +66,11 @@ > private final static List IDENTITY_TYPES; > > private final static List VALUE_STRATEGY_LIST; > + > + /** > + * @plexus.requirement > + */ > + private SQLReservedWords sqlReservedWords; > > private String valueStrategyOverride; > > @@ -241,6 +249,12 @@ > > printWriter.close(); > } > + > + private String violatesSqlReserved( String word ) > + { > + return "(Violates following tracked SQL Reserved Word Sources: " > + + sqlReservedWords.getKeywordSourceString( word ) + > ")"; > + } > > private void writeClass( XMLWriter writer, ModelClass modelClass ) > throws ModelloException > @@ -278,12 +292,12 @@ > if ( !StringUtils.isEmpty( jpoxMetadata.getTable() ) ) > { > // Test Substitute Table Name. > - if ( DBKeywords.isReserved( jpoxMetadata.getTable() ) ) > + if ( sqlReservedWords.isKeyword( jpoxMetadata.getTable() ) ) > { > throw new ModelloException( "The JDO mapping generator has > detected the use of the " + > - "SQL Reserved word '" + jpoxMetadata.getTable() + "' as > an alternative" + "table name for the " + > - modelClass.getName() + " class. Please use" + "a > different name for the <class jpox.table=\"" + > - jpoxMetadata.getTable() + "\"> attribute. See " + > DBKeywords.URL_SQL92 + " for complete list." ); > + "SQL Reserved word '" + jpoxMetadata.getTable() + "' as > an alternative table name for the " + > + modelClass.getName() + " class. Please use a different > name for the <class jpox.table=\"" + > + jpoxMetadata.getTable() + "\"> attribute. " + > violatesSqlReserved( jpoxMetadata.getTable() ) ); > } > > writer.addAttribute( "table", jpoxMetadata.getTable() ); > @@ -291,13 +305,13 @@ > else > { > // Test base table name. > - if ( DBKeywords.isReserved( modelClass.getName() ) ) > + if ( sqlReservedWords.isKeyword( modelClass.getName() ) ) > { > throw new ModelloException( "The JDO mapping generator has > detected the use of the " + > "SQL Reserved word '" + modelClass.getName() + "' as a > class name. " + > "Please specify an alternative jpox table name using the > " + > - "<class jpox.table=\"\"> attribute, or use a different > class name. See " + DBKeywords.URL_SQL92 + > - " for complete list." ); > + "<class jpox.table=\"\"> attribute, or use a different > class name. " + > + violatesSqlReserved( modelClass.getName() ) ); > } > } > > @@ -588,14 +602,14 @@ > if ( StringUtils.isNotEmpty( jpoxMetadata.getColumnName() ) ) > { > // Test proposed Column Name. > - if ( DBKeywords.isReserved( jpoxMetadata.getColumnName() ) ) > + if ( sqlReservedWords.isKeyword( jpoxMetadata.getColumnName() ) ) > { > throw new ModelloException( "The JDO mapping generator has > detected the use of the " + > - "SQL Reserved word '" + jpoxMetadata.getColumnName() + > "' as an alternative" + > + "SQL Reserved word '" + jpoxMetadata.getColumnName() + > "' as an alternative " + > "column name for the " + modelField.getName() + " field > of the " + > - modelField.getModelClass().getName() + " class. Please > use" + > + modelField.getModelClass().getName() + " class. Please > use " + > "a different name for the <field jpox.column=\"" + > jpoxMetadata.getColumnName() + > - "\"> attribute. See " + DBKeywords.URL_SQL92 + " for > complete list." ); > + "\"> attribute. " + violatesSqlReserved( > jpoxMetadata.getColumnName() ) ); > } > > writer.addAttribute( "column", jpoxMetadata.getColumnName() ); > @@ -603,27 +617,27 @@ > else > { > // Test proposed Field name. > - if ( DBKeywords.isReserved( modelField.getName() ) ) > + if ( sqlReservedWords.isKeyword( modelField.getName() ) ) > { > throw new ModelloException( "The JDO mapping generator has > detected the use of the " + > "SQL Reserved word '" + modelField.getName() + "' as a > field name of the " + > modelField.getModelClass().getName() + " class. Please > specify an " + > "alternative jpox column name using the <field > jpox.column=\"\"> " + > - "attribute, or use a different class name. See " + > DBKeywords.URL_SQL92 + " for complete list." ); > + "attribute, or use a different class name. " + > violatesSqlReserved( modelField.getName() ) ); > } > } > > if ( StringUtils.isNotEmpty( jpoxMetadata.getJoinTableName() ) ) > { > // Test proposed name for the Join Table for the field. > - if ( DBKeywords.isReserved( jpoxMetadata.getJoinTableName() ) ) > + if ( sqlReservedWords.isKeyword( jpoxMetadata.getJoinTableName() > ) ) > { > throw new ModelloException( "The JDO mapping generator has > detected the use of the " + > "SQL Reserved word '" + jpoxMetadata.getJoinTableName() > + "' as name of a" + "join table for the " + > modelField.getName() + " field of the " + > modelField.getModelClass().getName() + > " class. Please specify" + "an alternative name for the > <field jpox.join-table=\"" + > - jpoxMetadata.getColumnName() + "\"> attribute. See " + > DBKeywords.URL_SQL92 + > - " for complete list." ); > + jpoxMetadata.getColumnName() + "\"> attribute. " + > + violatesSqlReserved( jpoxMetadata.getJoinTableName() ) ); > } > writer.addAttribute( "table", jpoxMetadata.getJoinTableName() ); > } > @@ -820,19 +834,6 @@ > } > } > > - private void writeExtension( XMLWriter writer, String vendorName, String > key, String value ) > - { > - writer.startElement( "extension" ); > - > - writer.addAttribute( "vendor-name", vendorName ); > - > - writer.addAttribute( "key", key ); > - > - writer.addAttribute( "value", value ); > - > - writer.endElement(); > - } > - > private boolean isInstantionApplicationType( ModelClass modelClass ) > { > List identifierFields = modelClass.getIdentifierFields( > getGeneratedVersion() ); > > > Modified: > > trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml > (819 => 820) > > --- > trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml > 2007-03-12 17:18:51 UTC (rev 819) > +++ > trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml > 2007-03-13 14:05:19 UTC (rev 820) > @@ -16,6 +16,11 @@ > <role>org.codehaus.modello.plugin.ModelloGenerator</role> > <role-hint>jpox-jdo-mapping</role-hint> > > <implementation>org.codehaus.modello.plugin.jpox.JPoxJdoMappingModelloGenerator</implementation> > + <requirements> > + <requirement> > + <role>org.codehaus.modello.db.SQLReservedWords</role> > + </requirement> > + </requirements> > </component> > > <component> > > > Modified: > trunk/modello-plugins/modello-plugin-jpox/src/test/resources/test.mdo > (819 => 820) > > --- trunk/modello-plugins/modello-plugin-jpox/src/test/resources/test.mdo > 2007-03-12 17:18:51 UTC (rev 819) > +++ trunk/modello-plugins/modello-plugin-jpox/src/test/resources/test.mdo > 2007-03-13 14:05:19 UTC (rev 820) > @@ -35,7 +35,7 @@ > </class> > > <class stash.storable="true" > - jpox.table="ROLES" > + jpox.table="SECURITY_ROLES" > jpox.not-persisted-fields="modelEncoding"> > <name>JdoRole</name> > <version>1.0.0+</version> > @@ -127,7 +127,8 @@ > true if this object is permanent. > </description> > </field> > - <field jpox.indexed="true"> > + <field jpox.indexed="true" > + jpox.column="SECURITY_OPERATIONS"> > <name>operation</name> > <version>1.0.0+</version> > <association stash.part="true" > @@ -136,7 +137,8 @@ > <multiplicity>1</multiplicity> > </association> > </field> > - <field jpox.indexed="true"> > + <field jpox.indexed="true" > + jpox.column="SECURITY_RESOURCES"> > <name>resource</name> > <version>1.0.0+</version> > <association stash.part="true" > @@ -235,7 +237,7 @@ > <type>String</type> > <identifier>true</identifier> > </field> > - <field> > + <field jpox.column="LAST_UPDATED"> > <name>timestamp</name> > <version>1.0.0+</version> > <type>Date</type> > > > ------------------------------------------------------------------------ > > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email >