View Javadoc
1   /**
2    *    Copyright 2006-2016 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.mybatis.generator.api;
17  
18  import static org.mybatis.generator.internal.util.StringUtility.isTrue;
19  import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
20  
21  import java.util.ArrayList;
22  import java.util.HashMap;
23  import java.util.Iterator;
24  import java.util.List;
25  import java.util.Map;
26  import java.util.Properties;
27  
28  import org.mybatis.generator.config.Context;
29  import org.mybatis.generator.config.GeneratedKey;
30  import org.mybatis.generator.config.JavaClientGeneratorConfiguration;
31  import org.mybatis.generator.config.JavaModelGeneratorConfiguration;
32  import org.mybatis.generator.config.ModelType;
33  import org.mybatis.generator.config.PropertyHolder;
34  import org.mybatis.generator.config.PropertyRegistry;
35  import org.mybatis.generator.config.SqlMapGeneratorConfiguration;
36  import org.mybatis.generator.config.TableConfiguration;
37  import org.mybatis.generator.internal.rules.ConditionalModelRules;
38  import org.mybatis.generator.internal.rules.FlatModelRules;
39  import org.mybatis.generator.internal.rules.HierarchicalModelRules;
40  import org.mybatis.generator.internal.rules.Rules;
41  
42  /**
43   * Base class for all code generator implementations. This class provides many
44   * of the housekeeping methods needed to implement a code generator, with only
45   * the actual code generation methods left unimplemented.
46   * 
47   * @author Jeff Butler
48   * 
49   */
50  public abstract class IntrospectedTable {
51      
52      /**
53       * The Enum TargetRuntime.
54       */
55      public enum TargetRuntime {
56          
57          /** The IBATI s2. */
58          IBATIS2, 
59          /** The MYBATI s3. */
60          MYBATIS3
61      }
62  
63      /**
64       * The Enum InternalAttribute.
65       */
66      protected enum InternalAttribute {
67          
68          /** The attr dao implementation type. */
69          ATTR_DAO_IMPLEMENTATION_TYPE,
70          
71          /** The attr dao interface type. */
72          ATTR_DAO_INTERFACE_TYPE,
73          
74          /** The attr primary key type. */
75          ATTR_PRIMARY_KEY_TYPE,
76          
77          /** The attr base record type. */
78          ATTR_BASE_RECORD_TYPE,
79          
80          /** The attr record with blobs type. */
81          ATTR_RECORD_WITH_BLOBS_TYPE,
82          
83          /** The attr example type. */
84          ATTR_EXAMPLE_TYPE,
85          
86          /** The ATT r_ ibati s2_ sq l_ ma p_ package. */
87          ATTR_IBATIS2_SQL_MAP_PACKAGE,
88          
89          /** The ATT r_ ibati s2_ sq l_ ma p_ fil e_ name. */
90          ATTR_IBATIS2_SQL_MAP_FILE_NAME,
91          
92          /** The ATT r_ ibati s2_ sq l_ ma p_ namespace. */
93          ATTR_IBATIS2_SQL_MAP_NAMESPACE,
94          
95          /** The ATT r_ mybati s3_ xm l_ mappe r_ package. */
96          ATTR_MYBATIS3_XML_MAPPER_PACKAGE,
97          
98          /** The ATT r_ mybati s3_ xm l_ mappe r_ fil e_ name. */
99          ATTR_MYBATIS3_XML_MAPPER_FILE_NAME,
100         
101         /** also used as XML Mapper namespace if a Java mapper is generated. */
102         ATTR_MYBATIS3_JAVA_MAPPER_TYPE,
103         
104         /** used as XML Mapper namespace if no client is generated. */
105         ATTR_MYBATIS3_FALLBACK_SQL_MAP_NAMESPACE,
106         
107         /** The attr fully qualified table name at runtime. */
108         ATTR_FULLY_QUALIFIED_TABLE_NAME_AT_RUNTIME,
109         
110         /** The attr aliased fully qualified table name at runtime. */
111         ATTR_ALIASED_FULLY_QUALIFIED_TABLE_NAME_AT_RUNTIME,
112         
113         /** The attr count by example statement id. */
114         ATTR_COUNT_BY_EXAMPLE_STATEMENT_ID,
115         
116         /** The attr delete by example statement id. */
117         ATTR_DELETE_BY_EXAMPLE_STATEMENT_ID,
118         
119         /** The attr delete by primary key statement id. */
120         ATTR_DELETE_BY_PRIMARY_KEY_STATEMENT_ID,
121         
122         /** The attr insert statement id. */
123         ATTR_INSERT_STATEMENT_ID,
124         
125         /** The attr insert selective statement id. */
126         ATTR_INSERT_SELECTIVE_STATEMENT_ID,
127         
128         /** The attr select all statement id. */
129         ATTR_SELECT_ALL_STATEMENT_ID,
130         
131         /** The attr select by example statement id. */
132         ATTR_SELECT_BY_EXAMPLE_STATEMENT_ID,
133         
134         /** The attr select by example with blobs statement id. */
135         ATTR_SELECT_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID,
136         
137         /** The attr select by primary key statement id. */
138         ATTR_SELECT_BY_PRIMARY_KEY_STATEMENT_ID,
139         
140         /** The attr update by example statement id. */
141         ATTR_UPDATE_BY_EXAMPLE_STATEMENT_ID,
142         
143         /** The attr update by example selective statement id. */
144         ATTR_UPDATE_BY_EXAMPLE_SELECTIVE_STATEMENT_ID,
145         
146         /** The attr update by example with blobs statement id. */
147         ATTR_UPDATE_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID,
148         
149         /** The attr update by primary key statement id. */
150         ATTR_UPDATE_BY_PRIMARY_KEY_STATEMENT_ID,
151         
152         /** The attr update by primary key selective statement id. */
153         ATTR_UPDATE_BY_PRIMARY_KEY_SELECTIVE_STATEMENT_ID,
154         
155         /** The attr update by primary key with blobs statement id. */
156         ATTR_UPDATE_BY_PRIMARY_KEY_WITH_BLOBS_STATEMENT_ID,
157         
158         /** The attr base result map id. */
159         ATTR_BASE_RESULT_MAP_ID,
160         
161         /** The attr result map with blobs id. */
162         ATTR_RESULT_MAP_WITH_BLOBS_ID,
163         
164         /** The attr example where clause id. */
165         ATTR_EXAMPLE_WHERE_CLAUSE_ID,
166         
167         /** The attr base column list id. */
168         ATTR_BASE_COLUMN_LIST_ID,
169         
170         /** The attr blob column list id. */
171         ATTR_BLOB_COLUMN_LIST_ID,
172         
173         /** The ATT r_ mybati s3_ updat e_ b y_ exampl e_ wher e_ claus e_ id. */
174         ATTR_MYBATIS3_UPDATE_BY_EXAMPLE_WHERE_CLAUSE_ID,
175         
176         /** The ATT r_ mybati s3_ sq l_ provide r_ type. */
177         ATTR_MYBATIS3_SQL_PROVIDER_TYPE
178     }
179 
180     /** The table configuration. */
181     protected TableConfiguration tableConfiguration;
182     
183     /** The fully qualified table. */
184     protected FullyQualifiedTable fullyQualifiedTable;
185     
186     /** The context. */
187     protected Context context;
188     
189     /** The rules. */
190     protected Rules rules;
191     
192     /** The primary key columns. */
193     protected List<IntrospectedColumn> primaryKeyColumns;
194     
195     /** The base columns. */
196     protected List<IntrospectedColumn> baseColumns;
197     
198     /** The blob columns. */
199     protected List<IntrospectedColumn> blobColumns;
200     
201     /** The target runtime. */
202     protected TargetRuntime targetRuntime;
203 
204     /**
205      * Attributes may be used by plugins to capture table related state between
206      * the different plugin calls.
207      */
208     protected Map<String, Object> attributes;
209 
210     /** Internal attributes are used to store commonly accessed items by all code generators. */
211     protected Map<IntrospectedTable.InternalAttribute, String> internalAttributes;
212     
213     /**
214      * Table remarks retrieved from database metadata
215      */
216     protected String remarks;
217     
218     /**
219      * Table type retrieved from database metadata
220      */
221     protected String tableType;
222 
223     /**
224      * Instantiates a new introspected table.
225      *
226      * @param targetRuntime
227      *            the target runtime
228      */
229     public IntrospectedTable(TargetRuntime targetRuntime) {
230         super();
231         this.targetRuntime = targetRuntime;
232         primaryKeyColumns = new ArrayList<IntrospectedColumn>();
233         baseColumns = new ArrayList<IntrospectedColumn>();
234         blobColumns = new ArrayList<IntrospectedColumn>();
235         attributes = new HashMap<String, Object>();
236         internalAttributes = new HashMap<IntrospectedTable.InternalAttribute, String>();
237     }
238 
239     /**
240      * Gets the fully qualified table.
241      *
242      * @return the fully qualified table
243      */
244     public FullyQualifiedTable getFullyQualifiedTable() {
245         return fullyQualifiedTable;
246     }
247 
248     /**
249      * Gets the select by example query id.
250      *
251      * @return the select by example query id
252      */
253     public String getSelectByExampleQueryId() {
254         return tableConfiguration.getSelectByExampleQueryId();
255     }
256 
257     /**
258      * Gets the select by primary key query id.
259      *
260      * @return the select by primary key query id
261      */
262     public String getSelectByPrimaryKeyQueryId() {
263         return tableConfiguration.getSelectByPrimaryKeyQueryId();
264     }
265 
266     /**
267      * Gets the generated key.
268      *
269      * @return the generated key
270      */
271     public GeneratedKey getGeneratedKey() {
272         return tableConfiguration.getGeneratedKey();
273     }
274 
275     /**
276      * Gets the column.
277      *
278      * @param columnName
279      *            the column name
280      * @return the column
281      */
282     public IntrospectedColumn getColumn(String columnName) {
283         if (columnName == null) {
284             return null;
285         } else {
286             // search primary key columns
287             for (IntrospectedColumn introspectedColumn : primaryKeyColumns) {
288                 if (introspectedColumn.isColumnNameDelimited()) {
289                     if (introspectedColumn.getActualColumnName().equals(
290                             columnName)) {
291                         return introspectedColumn;
292                     }
293                 } else {
294                     if (introspectedColumn.getActualColumnName()
295                             .equalsIgnoreCase(columnName)) {
296                         return introspectedColumn;
297                     }
298                 }
299             }
300 
301             // search base columns
302             for (IntrospectedColumn introspectedColumn : baseColumns) {
303                 if (introspectedColumn.isColumnNameDelimited()) {
304                     if (introspectedColumn.getActualColumnName().equals(
305                             columnName)) {
306                         return introspectedColumn;
307                     }
308                 } else {
309                     if (introspectedColumn.getActualColumnName()
310                             .equalsIgnoreCase(columnName)) {
311                         return introspectedColumn;
312                     }
313                 }
314             }
315 
316             // search blob columns
317             for (IntrospectedColumn introspectedColumn : blobColumns) {
318                 if (introspectedColumn.isColumnNameDelimited()) {
319                     if (introspectedColumn.getActualColumnName().equals(
320                             columnName)) {
321                         return introspectedColumn;
322                     }
323                 } else {
324                     if (introspectedColumn.getActualColumnName()
325                             .equalsIgnoreCase(columnName)) {
326                         return introspectedColumn;
327                     }
328                 }
329             }
330 
331             return null;
332         }
333     }
334 
335     /**
336      * Returns true if any of the columns in the table are JDBC Dates (as
337      * opposed to timestamps).
338      * 
339      * @return true if the table contains DATE columns
340      */
341     public boolean hasJDBCDateColumns() {
342         boolean rc = false;
343 
344         for (IntrospectedColumn introspectedColumn : primaryKeyColumns) {
345             if (introspectedColumn.isJDBCDateColumn()) {
346                 rc = true;
347                 break;
348             }
349         }
350 
351         if (!rc) {
352             for (IntrospectedColumn introspectedColumn : baseColumns) {
353                 if (introspectedColumn.isJDBCDateColumn()) {
354                     rc = true;
355                     break;
356                 }
357             }
358         }
359 
360         return rc;
361     }
362 
363     /**
364      * Returns true if any of the columns in the table are JDBC Times (as
365      * opposed to timestamps).
366      * 
367      * @return true if the table contains TIME columns
368      */
369     public boolean hasJDBCTimeColumns() {
370         boolean rc = false;
371 
372         for (IntrospectedColumn introspectedColumn : primaryKeyColumns) {
373             if (introspectedColumn.isJDBCTimeColumn()) {
374                 rc = true;
375                 break;
376             }
377         }
378 
379         if (!rc) {
380             for (IntrospectedColumn introspectedColumn : baseColumns) {
381                 if (introspectedColumn.isJDBCTimeColumn()) {
382                     rc = true;
383                     break;
384                 }
385             }
386         }
387 
388         return rc;
389     }
390 
391     /**
392      * Returns the columns in the primary key. If the generatePrimaryKeyClass()
393      * method returns false, then these columns will be iterated as the
394      * parameters of the selectByPrimaryKay and deleteByPrimaryKey methods
395      * 
396      * @return a List of ColumnDefinition objects for columns in the primary key
397      */
398     public List<IntrospectedColumn> getPrimaryKeyColumns() {
399         return primaryKeyColumns;
400     }
401 
402     /**
403      * Checks for primary key columns.
404      *
405      * @return true, if successful
406      */
407     public boolean hasPrimaryKeyColumns() {
408         return primaryKeyColumns.size() > 0;
409     }
410 
411     /**
412      * Gets the base columns.
413      *
414      * @return the base columns
415      */
416     public List<IntrospectedColumn> getBaseColumns() {
417         return baseColumns;
418     }
419 
420     /**
421      * Returns all columns in the table (for use by the select by primary key and select by example with BLOBs methods).
422      *
423      * @return a List of ColumnDefinition objects for all columns in the table
424      */
425     public List<IntrospectedColumn> getAllColumns() {
426         List<IntrospectedColumn> answer = new ArrayList<IntrospectedColumn>();
427         answer.addAll(primaryKeyColumns);
428         answer.addAll(baseColumns);
429         answer.addAll(blobColumns);
430 
431         return answer;
432     }
433 
434     /**
435      * Returns all columns except BLOBs (for use by the select by example without BLOBs method).
436      *
437      * @return a List of ColumnDefinition objects for columns in the table that are non BLOBs
438      */
439     public List<IntrospectedColumn> getNonBLOBColumns() {
440         List<IntrospectedColumn> answer = new ArrayList<IntrospectedColumn>();
441         answer.addAll(primaryKeyColumns);
442         answer.addAll(baseColumns);
443 
444         return answer;
445     }
446 
447     /**
448      * Gets the non blob column count.
449      *
450      * @return the non blob column count
451      */
452     public int getNonBLOBColumnCount() {
453         return primaryKeyColumns.size() + baseColumns.size();
454     }
455 
456     /**
457      * Gets the non primary key columns.
458      *
459      * @return the non primary key columns
460      */
461     public List<IntrospectedColumn> getNonPrimaryKeyColumns() {
462         List<IntrospectedColumn> answer = new ArrayList<IntrospectedColumn>();
463         answer.addAll(baseColumns);
464         answer.addAll(blobColumns);
465 
466         return answer;
467     }
468 
469     /**
470      * Gets the BLOB columns.
471      *
472      * @return the BLOB columns
473      */
474     public List<IntrospectedColumn> getBLOBColumns() {
475         return blobColumns;
476     }
477 
478     /**
479      * Checks for blob columns.
480      *
481      * @return true, if successful
482      */
483     public boolean hasBLOBColumns() {
484         return blobColumns.size() > 0;
485     }
486 
487     /**
488      * Checks for base columns.
489      *
490      * @return true, if successful
491      */
492     public boolean hasBaseColumns() {
493         return baseColumns.size() > 0;
494     }
495 
496     /**
497      * Gets the rules.
498      *
499      * @return the rules
500      */
501     public Rules getRules() {
502         return rules;
503     }
504 
505     /**
506      * Gets the table configuration property.
507      *
508      * @param property
509      *            the property
510      * @return the table configuration property
511      */
512     public String getTableConfigurationProperty(String property) {
513         return tableConfiguration.getProperty(property);
514     }
515 
516     /**
517      * Gets the primary key type.
518      *
519      * @return the primary key type
520      */
521     public String getPrimaryKeyType() {
522         return internalAttributes.get(InternalAttribute.ATTR_PRIMARY_KEY_TYPE);
523     }
524 
525     /**
526      * Gets the base record type.
527      *
528      * @return the type for the record (the class that holds non-primary key and non-BLOB fields). Note that the value
529      *         will be calculated regardless of whether the table has these columns or not.
530      */
531     public String getBaseRecordType() {
532         return internalAttributes.get(InternalAttribute.ATTR_BASE_RECORD_TYPE);
533     }
534 
535     /**
536      * Gets the example type.
537      *
538      * @return the type for the example class.
539      */
540     public String getExampleType() {
541         return internalAttributes.get(InternalAttribute.ATTR_EXAMPLE_TYPE);
542     }
543 
544     /**
545      * Gets the record with blo bs type.
546      *
547      * @return the type for the record with BLOBs class. Note that the value will be calculated regardless of whether
548      *         the table has BLOB columns or not.
549      */
550     public String getRecordWithBLOBsType() {
551         return internalAttributes
552                 .get(InternalAttribute.ATTR_RECORD_WITH_BLOBS_TYPE);
553     }
554 
555     /**
556      * Calculates an SQL Map file name for the table. Typically the name is
557      * "XXXX_SqlMap.xml" where XXXX is the fully qualified table name (delimited
558      * with underscores).
559      * 
560      * @return the name of the SqlMap file
561      */
562     public String getIbatis2SqlMapFileName() {
563         return internalAttributes
564                 .get(InternalAttribute.ATTR_IBATIS2_SQL_MAP_FILE_NAME);
565     }
566 
567     /**
568      * Gets the ibatis2 sql map namespace.
569      *
570      * @return the ibatis2 sql map namespace
571      */
572     public String getIbatis2SqlMapNamespace() {
573         return internalAttributes
574                 .get(InternalAttribute.ATTR_IBATIS2_SQL_MAP_NAMESPACE);
575     }
576 
577     /**
578      * Gets the my batis3 sql map namespace.
579      *
580      * @return the my batis3 sql map namespace
581      */
582     public String getMyBatis3SqlMapNamespace() {
583         String namespace = getMyBatis3JavaMapperType();
584         if (namespace == null) {
585             namespace = getMyBatis3FallbackSqlMapNamespace();
586         }
587         
588         return namespace;
589     }
590     
591     /**
592      * Gets the my batis3 fallback sql map namespace.
593      *
594      * @return the my batis3 fallback sql map namespace
595      */
596     public String getMyBatis3FallbackSqlMapNamespace() {
597         return internalAttributes
598                 .get(InternalAttribute.ATTR_MYBATIS3_FALLBACK_SQL_MAP_NAMESPACE);
599     }
600     
601     /**
602      * Calculates the package for the current table.
603      * 
604      * @return the package for the SqlMap for the current table
605      */
606     public String getIbatis2SqlMapPackage() {
607         return internalAttributes
608                 .get(InternalAttribute.ATTR_IBATIS2_SQL_MAP_PACKAGE);
609     }
610 
611     /**
612      * Gets the DAO implementation type.
613      *
614      * @return the DAO implementation type
615      */
616     public String getDAOImplementationType() {
617         return internalAttributes
618                 .get(InternalAttribute.ATTR_DAO_IMPLEMENTATION_TYPE);
619     }
620 
621     /**
622      * Gets the DAO interface type.
623      *
624      * @return the DAO interface type
625      */
626     public String getDAOInterfaceType() {
627         return internalAttributes
628                 .get(InternalAttribute.ATTR_DAO_INTERFACE_TYPE);
629     }
630 
631     /**
632      * Checks for any columns.
633      *
634      * @return true, if successful
635      */
636     public boolean hasAnyColumns() {
637         return primaryKeyColumns.size() > 0 || baseColumns.size() > 0
638                 || blobColumns.size() > 0;
639     }
640 
641     /**
642      * Sets the table configuration.
643      *
644      * @param tableConfiguration
645      *            the new table configuration
646      */
647     public void setTableConfiguration(TableConfiguration tableConfiguration) {
648         this.tableConfiguration = tableConfiguration;
649     }
650 
651     /**
652      * Sets the fully qualified table.
653      *
654      * @param fullyQualifiedTable
655      *            the new fully qualified table
656      */
657     public void setFullyQualifiedTable(FullyQualifiedTable fullyQualifiedTable) {
658         this.fullyQualifiedTable = fullyQualifiedTable;
659     }
660 
661     /**
662      * Sets the context.
663      *
664      * @param context
665      *            the new context
666      */
667     public void setContext(Context context) {
668         this.context = context;
669     }
670 
671     /**
672      * Adds the column.
673      *
674      * @param introspectedColumn
675      *            the introspected column
676      */
677     public void addColumn(IntrospectedColumn introspectedColumn) {
678         if (introspectedColumn.isBLOBColumn()) {
679             blobColumns.add(introspectedColumn);
680         } else {
681             baseColumns.add(introspectedColumn);
682         }
683 
684         introspectedColumn.setIntrospectedTable(this);
685     }
686 
687     /**
688      * Adds the primary key column.
689      *
690      * @param columnName
691      *            the column name
692      */
693     public void addPrimaryKeyColumn(String columnName) {
694         boolean found = false;
695         // first search base columns
696         Iterator<IntrospectedColumn> iter = baseColumns.iterator();
697         while (iter.hasNext()) {
698             IntrospectedColumn introspectedColumn = iter.next();
699             if (introspectedColumn.getActualColumnName().equals(columnName)) {
700                 primaryKeyColumns.add(introspectedColumn);
701                 iter.remove();
702                 found = true;
703                 break;
704             }
705         }
706 
707         // search blob columns in the weird event that a blob is the primary key
708         if (!found) {
709             iter = blobColumns.iterator();
710             while (iter.hasNext()) {
711                 IntrospectedColumn introspectedColumn = iter.next();
712                 if (introspectedColumn.getActualColumnName().equals(columnName)) {
713                     primaryKeyColumns.add(introspectedColumn);
714                     iter.remove();
715                     found = true;
716                     break;
717                 }
718             }
719         }
720     }
721 
722     /**
723      * Gets the attribute.
724      *
725      * @param name
726      *            the name
727      * @return the attribute
728      */
729     public Object getAttribute(String name) {
730         return attributes.get(name);
731     }
732 
733     /**
734      * Removes the attribute.
735      *
736      * @param name
737      *            the name
738      */
739     public void removeAttribute(String name) {
740         attributes.remove(name);
741     }
742 
743     /**
744      * Sets the attribute.
745      *
746      * @param name
747      *            the name
748      * @param value
749      *            the value
750      */
751     public void setAttribute(String name, Object value) {
752         attributes.put(name, value);
753     }
754 
755     /**
756      * Initialize.
757      */
758     public void initialize() {
759         calculateJavaClientAttributes();
760         calculateModelAttributes();
761         calculateXmlAttributes();
762 
763         if (tableConfiguration.getModelType() == ModelType.HIERARCHICAL) {
764             rules = new HierarchicalModelRules(this);
765         } else if (tableConfiguration.getModelType() == ModelType.FLAT) {
766             rules = new FlatModelRules(this);
767         } else {
768             rules = new ConditionalModelRules(this);
769         }
770 
771         context.getPlugins().initialized(this);
772     }
773 
774     /**
775      * Calculate xml attributes.
776      */
777     protected void calculateXmlAttributes() {
778         setIbatis2SqlMapPackage(calculateSqlMapPackage());
779         setIbatis2SqlMapFileName(calculateIbatis2SqlMapFileName());
780         setMyBatis3XmlMapperFileName(calculateMyBatis3XmlMapperFileName());
781         setMyBatis3XmlMapperPackage(calculateSqlMapPackage());
782 
783         setIbatis2SqlMapNamespace(calculateIbatis2SqlMapNamespace());
784         setMyBatis3FallbackSqlMapNamespace(calculateMyBatis3FallbackSqlMapNamespace());
785         
786         setSqlMapFullyQualifiedRuntimeTableName(calculateSqlMapFullyQualifiedRuntimeTableName());
787         setSqlMapAliasedFullyQualifiedRuntimeTableName(calculateSqlMapAliasedFullyQualifiedRuntimeTableName());
788 
789         setCountByExampleStatementId("countByExample"); //$NON-NLS-1$
790         setDeleteByExampleStatementId("deleteByExample"); //$NON-NLS-1$
791         setDeleteByPrimaryKeyStatementId("deleteByPrimaryKey"); //$NON-NLS-1$
792         setInsertStatementId("insert"); //$NON-NLS-1$
793         setInsertSelectiveStatementId("insertSelective"); //$NON-NLS-1$
794         setSelectAllStatementId("selectAll"); //$NON-NLS-1$
795         setSelectByExampleStatementId("selectByExample"); //$NON-NLS-1$
796         setSelectByExampleWithBLOBsStatementId("selectByExampleWithBLOBs"); //$NON-NLS-1$
797         setSelectByPrimaryKeyStatementId("selectByPrimaryKey"); //$NON-NLS-1$
798         setUpdateByExampleStatementId("updateByExample"); //$NON-NLS-1$
799         setUpdateByExampleSelectiveStatementId("updateByExampleSelective"); //$NON-NLS-1$
800         setUpdateByExampleWithBLOBsStatementId("updateByExampleWithBLOBs"); //$NON-NLS-1$
801         setUpdateByPrimaryKeyStatementId("updateByPrimaryKey"); //$NON-NLS-1$
802         setUpdateByPrimaryKeySelectiveStatementId("updateByPrimaryKeySelective"); //$NON-NLS-1$
803         setUpdateByPrimaryKeyWithBLOBsStatementId("updateByPrimaryKeyWithBLOBs"); //$NON-NLS-1$
804         setBaseResultMapId("BaseResultMap"); //$NON-NLS-1$
805         setResultMapWithBLOBsId("ResultMapWithBLOBs"); //$NON-NLS-1$
806         setExampleWhereClauseId("Example_Where_Clause"); //$NON-NLS-1$
807         setBaseColumnListId("Base_Column_List"); //$NON-NLS-1$
808         setBlobColumnListId("Blob_Column_List"); //$NON-NLS-1$
809         setMyBatis3UpdateByExampleWhereClauseId("Update_By_Example_Where_Clause"); //$NON-NLS-1$
810     }
811 
812     /**
813      * Sets the blob column list id.
814      *
815      * @param s
816      *            the new blob column list id
817      */
818     public void setBlobColumnListId(String s) {
819         internalAttributes.put(InternalAttribute.ATTR_BLOB_COLUMN_LIST_ID, s);
820     }
821 
822     /**
823      * Sets the base column list id.
824      *
825      * @param s
826      *            the new base column list id
827      */
828     public void setBaseColumnListId(String s) {
829         internalAttributes.put(InternalAttribute.ATTR_BASE_COLUMN_LIST_ID, s);
830     }
831 
832     /**
833      * Sets the example where clause id.
834      *
835      * @param s
836      *            the new example where clause id
837      */
838     public void setExampleWhereClauseId(String s) {
839         internalAttributes.put(InternalAttribute.ATTR_EXAMPLE_WHERE_CLAUSE_ID,
840                 s);
841     }
842 
843     /**
844      * Sets the my batis3 update by example where clause id.
845      *
846      * @param s
847      *            the new my batis3 update by example where clause id
848      */
849     public void setMyBatis3UpdateByExampleWhereClauseId(String s) {
850         internalAttributes
851                 .put(
852                         InternalAttribute.ATTR_MYBATIS3_UPDATE_BY_EXAMPLE_WHERE_CLAUSE_ID,
853                         s);
854     }
855 
856     /**
857      * Sets the result map with blo bs id.
858      *
859      * @param s
860      *            the new result map with blo bs id
861      */
862     public void setResultMapWithBLOBsId(String s) {
863         internalAttributes.put(InternalAttribute.ATTR_RESULT_MAP_WITH_BLOBS_ID,
864                 s);
865     }
866 
867     /**
868      * Sets the base result map id.
869      *
870      * @param s
871      *            the new base result map id
872      */
873     public void setBaseResultMapId(String s) {
874         internalAttributes.put(InternalAttribute.ATTR_BASE_RESULT_MAP_ID, s);
875     }
876 
877     /**
878      * Sets the update by primary key with blo bs statement id.
879      *
880      * @param s
881      *            the new update by primary key with blo bs statement id
882      */
883     public void setUpdateByPrimaryKeyWithBLOBsStatementId(String s) {
884         internalAttributes
885                 .put(
886                         InternalAttribute.ATTR_UPDATE_BY_PRIMARY_KEY_WITH_BLOBS_STATEMENT_ID,
887                         s);
888     }
889 
890     /**
891      * Sets the update by primary key selective statement id.
892      *
893      * @param s
894      *            the new update by primary key selective statement id
895      */
896     public void setUpdateByPrimaryKeySelectiveStatementId(String s) {
897         internalAttributes
898                 .put(
899                         InternalAttribute.ATTR_UPDATE_BY_PRIMARY_KEY_SELECTIVE_STATEMENT_ID,
900                         s);
901     }
902 
903     /**
904      * Sets the update by primary key statement id.
905      *
906      * @param s
907      *            the new update by primary key statement id
908      */
909     public void setUpdateByPrimaryKeyStatementId(String s) {
910         internalAttributes.put(
911                 InternalAttribute.ATTR_UPDATE_BY_PRIMARY_KEY_STATEMENT_ID, s);
912     }
913 
914     /**
915      * Sets the update by example with blo bs statement id.
916      *
917      * @param s
918      *            the new update by example with blo bs statement id
919      */
920     public void setUpdateByExampleWithBLOBsStatementId(String s) {
921         internalAttributes
922                 .put(
923                         InternalAttribute.ATTR_UPDATE_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID,
924                         s);
925     }
926 
927     /**
928      * Sets the update by example selective statement id.
929      *
930      * @param s
931      *            the new update by example selective statement id
932      */
933     public void setUpdateByExampleSelectiveStatementId(String s) {
934         internalAttributes
935                 .put(
936                         InternalAttribute.ATTR_UPDATE_BY_EXAMPLE_SELECTIVE_STATEMENT_ID,
937                         s);
938     }
939 
940     /**
941      * Sets the update by example statement id.
942      *
943      * @param s
944      *            the new update by example statement id
945      */
946     public void setUpdateByExampleStatementId(String s) {
947         internalAttributes.put(
948                 InternalAttribute.ATTR_UPDATE_BY_EXAMPLE_STATEMENT_ID, s);
949     }
950 
951     /**
952      * Sets the select by primary key statement id.
953      *
954      * @param s
955      *            the new select by primary key statement id
956      */
957     public void setSelectByPrimaryKeyStatementId(String s) {
958         internalAttributes.put(
959                 InternalAttribute.ATTR_SELECT_BY_PRIMARY_KEY_STATEMENT_ID, s);
960     }
961 
962     /**
963      * Sets the select by example with blo bs statement id.
964      *
965      * @param s
966      *            the new select by example with blo bs statement id
967      */
968     public void setSelectByExampleWithBLOBsStatementId(String s) {
969         internalAttributes
970                 .put(
971                         InternalAttribute.ATTR_SELECT_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID,
972                         s);
973     }
974 
975     /**
976      * Sets the select all statement id.
977      *
978      * @param s
979      *            the new select all statement id
980      */
981     public void setSelectAllStatementId(String s) {
982         internalAttributes.put(
983                 InternalAttribute.ATTR_SELECT_ALL_STATEMENT_ID, s);
984     }
985 
986     /**
987      * Sets the select by example statement id.
988      *
989      * @param s
990      *            the new select by example statement id
991      */
992     public void setSelectByExampleStatementId(String s) {
993         internalAttributes.put(
994                 InternalAttribute.ATTR_SELECT_BY_EXAMPLE_STATEMENT_ID, s);
995     }
996 
997     /**
998      * Sets the insert selective statement id.
999      *
1000      * @param s
1001      *            the new insert selective statement id
1002      */
1003     public void setInsertSelectiveStatementId(String s) {
1004         internalAttributes.put(
1005                 InternalAttribute.ATTR_INSERT_SELECTIVE_STATEMENT_ID, s);
1006     }
1007 
1008     /**
1009      * Sets the insert statement id.
1010      *
1011      * @param s
1012      *            the new insert statement id
1013      */
1014     public void setInsertStatementId(String s) {
1015         internalAttributes.put(InternalAttribute.ATTR_INSERT_STATEMENT_ID, s);
1016     }
1017 
1018     /**
1019      * Sets the delete by primary key statement id.
1020      *
1021      * @param s
1022      *            the new delete by primary key statement id
1023      */
1024     public void setDeleteByPrimaryKeyStatementId(String s) {
1025         internalAttributes.put(
1026                 InternalAttribute.ATTR_DELETE_BY_PRIMARY_KEY_STATEMENT_ID, s);
1027     }
1028 
1029     /**
1030      * Sets the delete by example statement id.
1031      *
1032      * @param s
1033      *            the new delete by example statement id
1034      */
1035     public void setDeleteByExampleStatementId(String s) {
1036         internalAttributes.put(
1037                 InternalAttribute.ATTR_DELETE_BY_EXAMPLE_STATEMENT_ID, s);
1038     }
1039 
1040     /**
1041      * Sets the count by example statement id.
1042      *
1043      * @param s
1044      *            the new count by example statement id
1045      */
1046     public void setCountByExampleStatementId(String s) {
1047         internalAttributes.put(
1048                 InternalAttribute.ATTR_COUNT_BY_EXAMPLE_STATEMENT_ID, s);
1049     }
1050 
1051     /**
1052      * Gets the blob column list id.
1053      *
1054      * @return the blob column list id
1055      */
1056     public String getBlobColumnListId() {
1057         return internalAttributes
1058                 .get(InternalAttribute.ATTR_BLOB_COLUMN_LIST_ID);
1059     }
1060 
1061     /**
1062      * Gets the base column list id.
1063      *
1064      * @return the base column list id
1065      */
1066     public String getBaseColumnListId() {
1067         return internalAttributes
1068                 .get(InternalAttribute.ATTR_BASE_COLUMN_LIST_ID);
1069     }
1070 
1071     /**
1072      * Gets the example where clause id.
1073      *
1074      * @return the example where clause id
1075      */
1076     public String getExampleWhereClauseId() {
1077         return internalAttributes
1078                 .get(InternalAttribute.ATTR_EXAMPLE_WHERE_CLAUSE_ID);
1079     }
1080 
1081     /**
1082      * Gets the my batis3 update by example where clause id.
1083      *
1084      * @return the my batis3 update by example where clause id
1085      */
1086     public String getMyBatis3UpdateByExampleWhereClauseId() {
1087         return internalAttributes
1088                 .get(InternalAttribute.ATTR_MYBATIS3_UPDATE_BY_EXAMPLE_WHERE_CLAUSE_ID);
1089     }
1090 
1091     /**
1092      * Gets the result map with blo bs id.
1093      *
1094      * @return the result map with blo bs id
1095      */
1096     public String getResultMapWithBLOBsId() {
1097         return internalAttributes
1098                 .get(InternalAttribute.ATTR_RESULT_MAP_WITH_BLOBS_ID);
1099     }
1100 
1101     /**
1102      * Gets the base result map id.
1103      *
1104      * @return the base result map id
1105      */
1106     public String getBaseResultMapId() {
1107         return internalAttributes
1108                 .get(InternalAttribute.ATTR_BASE_RESULT_MAP_ID);
1109     }
1110 
1111     /**
1112      * Gets the update by primary key with blo bs statement id.
1113      *
1114      * @return the update by primary key with blo bs statement id
1115      */
1116     public String getUpdateByPrimaryKeyWithBLOBsStatementId() {
1117         return internalAttributes
1118                 .get(InternalAttribute.ATTR_UPDATE_BY_PRIMARY_KEY_WITH_BLOBS_STATEMENT_ID);
1119     }
1120 
1121     /**
1122      * Gets the update by primary key selective statement id.
1123      *
1124      * @return the update by primary key selective statement id
1125      */
1126     public String getUpdateByPrimaryKeySelectiveStatementId() {
1127         return internalAttributes
1128                 .get(InternalAttribute.ATTR_UPDATE_BY_PRIMARY_KEY_SELECTIVE_STATEMENT_ID);
1129     }
1130 
1131     /**
1132      * Gets the update by primary key statement id.
1133      *
1134      * @return the update by primary key statement id
1135      */
1136     public String getUpdateByPrimaryKeyStatementId() {
1137         return internalAttributes
1138                 .get(InternalAttribute.ATTR_UPDATE_BY_PRIMARY_KEY_STATEMENT_ID);
1139     }
1140 
1141     /**
1142      * Gets the update by example with blo bs statement id.
1143      *
1144      * @return the update by example with blo bs statement id
1145      */
1146     public String getUpdateByExampleWithBLOBsStatementId() {
1147         return internalAttributes
1148                 .get(InternalAttribute.ATTR_UPDATE_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID);
1149     }
1150 
1151     /**
1152      * Gets the update by example selective statement id.
1153      *
1154      * @return the update by example selective statement id
1155      */
1156     public String getUpdateByExampleSelectiveStatementId() {
1157         return internalAttributes
1158                 .get(InternalAttribute.ATTR_UPDATE_BY_EXAMPLE_SELECTIVE_STATEMENT_ID);
1159     }
1160 
1161     /**
1162      * Gets the update by example statement id.
1163      *
1164      * @return the update by example statement id
1165      */
1166     public String getUpdateByExampleStatementId() {
1167         return internalAttributes
1168                 .get(InternalAttribute.ATTR_UPDATE_BY_EXAMPLE_STATEMENT_ID);
1169     }
1170 
1171     /**
1172      * Gets the select by primary key statement id.
1173      *
1174      * @return the select by primary key statement id
1175      */
1176     public String getSelectByPrimaryKeyStatementId() {
1177         return internalAttributes
1178                 .get(InternalAttribute.ATTR_SELECT_BY_PRIMARY_KEY_STATEMENT_ID);
1179     }
1180 
1181     /**
1182      * Gets the select by example with blo bs statement id.
1183      *
1184      * @return the select by example with blo bs statement id
1185      */
1186     public String getSelectByExampleWithBLOBsStatementId() {
1187         return internalAttributes
1188                 .get(InternalAttribute.ATTR_SELECT_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID);
1189     }
1190 
1191     /**
1192      * Gets the select all statement id.
1193      *
1194      * @return the select all statement id
1195      */
1196     public String getSelectAllStatementId() {
1197         return internalAttributes
1198                 .get(InternalAttribute.ATTR_SELECT_ALL_STATEMENT_ID);
1199     }
1200 
1201     /**
1202      * Gets the select by example statement id.
1203      *
1204      * @return the select by example statement id
1205      */
1206     public String getSelectByExampleStatementId() {
1207         return internalAttributes
1208                 .get(InternalAttribute.ATTR_SELECT_BY_EXAMPLE_STATEMENT_ID);
1209     }
1210 
1211     /**
1212      * Gets the insert selective statement id.
1213      *
1214      * @return the insert selective statement id
1215      */
1216     public String getInsertSelectiveStatementId() {
1217         return internalAttributes
1218                 .get(InternalAttribute.ATTR_INSERT_SELECTIVE_STATEMENT_ID);
1219     }
1220 
1221     /**
1222      * Gets the insert statement id.
1223      *
1224      * @return the insert statement id
1225      */
1226     public String getInsertStatementId() {
1227         return internalAttributes
1228                 .get(InternalAttribute.ATTR_INSERT_STATEMENT_ID);
1229     }
1230 
1231     /**
1232      * Gets the delete by primary key statement id.
1233      *
1234      * @return the delete by primary key statement id
1235      */
1236     public String getDeleteByPrimaryKeyStatementId() {
1237         return internalAttributes
1238                 .get(InternalAttribute.ATTR_DELETE_BY_PRIMARY_KEY_STATEMENT_ID);
1239     }
1240 
1241     /**
1242      * Gets the delete by example statement id.
1243      *
1244      * @return the delete by example statement id
1245      */
1246     public String getDeleteByExampleStatementId() {
1247         return internalAttributes
1248                 .get(InternalAttribute.ATTR_DELETE_BY_EXAMPLE_STATEMENT_ID);
1249     }
1250 
1251     /**
1252      * Gets the count by example statement id.
1253      *
1254      * @return the count by example statement id
1255      */
1256     public String getCountByExampleStatementId() {
1257         return internalAttributes
1258                 .get(InternalAttribute.ATTR_COUNT_BY_EXAMPLE_STATEMENT_ID);
1259     }
1260 
1261     /**
1262      * Calculate java client implementation package.
1263      *
1264      * @return the string
1265      */
1266     protected String calculateJavaClientImplementationPackage() {
1267         JavaClientGeneratorConfiguration config = context
1268                 .getJavaClientGeneratorConfiguration();
1269         if (config == null) {
1270             return null;
1271         }
1272 
1273         StringBuilder sb = new StringBuilder();
1274         if (stringHasValue(config.getImplementationPackage())) {
1275             sb.append(config.getImplementationPackage());
1276         } else {
1277             sb.append(config.getTargetPackage());
1278         }
1279 
1280         sb.append(fullyQualifiedTable.getSubPackage(isSubPackagesEnabled(config)));
1281 
1282         return sb.toString();
1283     }
1284     
1285     /**
1286      * Checks if is sub packages enabled.
1287      *
1288      * @param propertyHolder
1289      *            the property holder
1290      * @return true, if is sub packages enabled
1291      */
1292     private boolean isSubPackagesEnabled(PropertyHolder propertyHolder) {
1293         return isTrue(propertyHolder.getProperty(PropertyRegistry.ANY_ENABLE_SUB_PACKAGES));
1294     }
1295 
1296     /**
1297      * Calculate java client interface package.
1298      *
1299      * @return the string
1300      */
1301     protected String calculateJavaClientInterfacePackage() {
1302         JavaClientGeneratorConfiguration config = context
1303                 .getJavaClientGeneratorConfiguration();
1304         if (config == null) {
1305             return null;
1306         }
1307 
1308         StringBuilder sb = new StringBuilder();
1309         sb.append(config.getTargetPackage());
1310 
1311         sb.append(fullyQualifiedTable.getSubPackage(isSubPackagesEnabled(config)));
1312 
1313         return sb.toString();
1314     }
1315 
1316     /**
1317      * Calculate java client attributes.
1318      */
1319     protected void calculateJavaClientAttributes() {
1320         if (context.getJavaClientGeneratorConfiguration() == null) {
1321             return;
1322         }
1323 
1324         StringBuilder sb = new StringBuilder();
1325         sb.append(calculateJavaClientImplementationPackage());
1326         sb.append('.');
1327         sb.append(fullyQualifiedTable.getDomainObjectName());
1328         sb.append("DAOImpl"); //$NON-NLS-1$
1329         setDAOImplementationType(sb.toString());
1330 
1331         sb.setLength(0);
1332         sb.append(calculateJavaClientInterfacePackage());
1333         sb.append('.');
1334         sb.append(fullyQualifiedTable.getDomainObjectName());
1335         sb.append("DAO"); //$NON-NLS-1$
1336         setDAOInterfaceType(sb.toString());
1337 
1338         sb.setLength(0);
1339         sb.append(calculateJavaClientInterfacePackage());
1340         sb.append('.');
1341         sb.append(fullyQualifiedTable.getDomainObjectName());
1342         sb.append("Dao"); //$NON-NLS-1$
1343         setMyBatis3JavaMapperType(sb.toString());
1344 
1345         sb.setLength(0);
1346         sb.append(calculateJavaClientInterfacePackage());
1347         sb.append('.');
1348         sb.append(fullyQualifiedTable.getDomainObjectName());
1349         sb.append("SqlProvider"); //$NON-NLS-1$
1350         setMyBatis3SqlProviderType(sb.toString());
1351     }
1352 
1353     /**
1354      * Calculate java model package.
1355      *
1356      * @return the string
1357      */
1358     protected String calculateJavaModelPackage() {
1359         JavaModelGeneratorConfiguration config = context
1360                 .getJavaModelGeneratorConfiguration();
1361 
1362         StringBuilder sb = new StringBuilder();
1363         sb.append(config.getTargetPackage());
1364         sb.append(fullyQualifiedTable.getSubPackage(isSubPackagesEnabled(config)));
1365 
1366         return sb.toString();
1367     }
1368 
1369     /**
1370      * Calculate model attributes.
1371      */
1372     protected void calculateModelAttributes() {
1373         String pakkage = calculateJavaModelPackage();
1374 
1375         StringBuilder sb = new StringBuilder();
1376         sb.append(pakkage);
1377         sb.append('.');
1378         sb.append(fullyQualifiedTable.getDomainObjectName());
1379         sb.append("Key"); //$NON-NLS-1$
1380         setPrimaryKeyType(sb.toString());
1381 
1382         sb.setLength(0);
1383         sb.append(pakkage);
1384         sb.append('.');
1385         sb.append(fullyQualifiedTable.getDomainObjectName());
1386         setBaseRecordType(sb.toString());
1387 
1388         sb.setLength(0);
1389         sb.append(pakkage);
1390         sb.append('.');
1391         sb.append(fullyQualifiedTable.getDomainObjectName());
1392         sb.append("WithBLOBs"); //$NON-NLS-1$
1393         setRecordWithBLOBsType(sb.toString());
1394 
1395         sb.setLength(0);
1396         sb.append(pakkage);
1397         sb.append('.');
1398         sb.append(fullyQualifiedTable.getDomainObjectName());
1399         sb.append("Example"); //$NON-NLS-1$
1400         setExampleType(sb.toString());
1401     }
1402 
1403     /**
1404      * Calculate sql map package.
1405      *
1406      * @return the string
1407      */
1408     protected String calculateSqlMapPackage() {
1409         StringBuilder sb = new StringBuilder();
1410         SqlMapGeneratorConfiguration config = context
1411                 .getSqlMapGeneratorConfiguration();
1412         
1413         // config can be null if the Java client does not require XML
1414         if (config != null) {
1415             sb.append(config.getTargetPackage());
1416             sb.append(fullyQualifiedTable.getSubPackage(isSubPackagesEnabled(config)));
1417         }
1418 
1419         return sb.toString();
1420     }
1421 
1422     /**
1423      * Calculate ibatis2 sql map file name.
1424      *
1425      * @return the string
1426      */
1427     protected String calculateIbatis2SqlMapFileName() {
1428         StringBuilder sb = new StringBuilder();
1429         sb.append(fullyQualifiedTable.getIbatis2SqlMapNamespace());
1430         sb.append("_SqlMap.xml"); //$NON-NLS-1$
1431         return sb.toString();
1432     }
1433 
1434     /**
1435      * Calculate my batis3 xml mapper file name.
1436      *
1437      * @return the string
1438      */
1439     protected String calculateMyBatis3XmlMapperFileName() {
1440         StringBuilder sb = new StringBuilder();
1441         sb.append(fullyQualifiedTable.getDomainObjectName());
1442         sb.append("Mapper.xml"); //$NON-NLS-1$
1443         return sb.toString();
1444     }
1445 
1446     /**
1447      * Calculate ibatis2 sql map namespace.
1448      *
1449      * @return the string
1450      */
1451     protected String calculateIbatis2SqlMapNamespace() {
1452         return fullyQualifiedTable.getIbatis2SqlMapNamespace();
1453     }
1454     
1455     /**
1456      * Calculate my batis3 fallback sql map namespace.
1457      *
1458      * @return the string
1459      */
1460     protected String calculateMyBatis3FallbackSqlMapNamespace() {
1461         StringBuilder sb = new StringBuilder();
1462         sb.append(calculateSqlMapPackage());
1463         sb.append('.');
1464         sb.append(fullyQualifiedTable.getDomainObjectName());
1465         sb.append("Mapper"); //$NON-NLS-1$
1466         return sb.toString();
1467     }
1468 
1469     /**
1470      * Calculate sql map fully qualified runtime table name.
1471      *
1472      * @return the string
1473      */
1474     protected String calculateSqlMapFullyQualifiedRuntimeTableName() {
1475         return fullyQualifiedTable.getFullyQualifiedTableNameAtRuntime();
1476     }
1477 
1478     /**
1479      * Calculate sql map aliased fully qualified runtime table name.
1480      *
1481      * @return the string
1482      */
1483     protected String calculateSqlMapAliasedFullyQualifiedRuntimeTableName() {
1484         return fullyQualifiedTable.getAliasedFullyQualifiedTableNameAtRuntime();
1485     }
1486 
1487     /**
1488      * Gets the fully qualified table name at runtime.
1489      *
1490      * @return the fully qualified table name at runtime
1491      */
1492     public String getFullyQualifiedTableNameAtRuntime() {
1493         return internalAttributes
1494                 .get(InternalAttribute.ATTR_FULLY_QUALIFIED_TABLE_NAME_AT_RUNTIME);
1495     }
1496 
1497     /**
1498      * Gets the aliased fully qualified table name at runtime.
1499      *
1500      * @return the aliased fully qualified table name at runtime
1501      */
1502     public String getAliasedFullyQualifiedTableNameAtRuntime() {
1503         return internalAttributes
1504                 .get(InternalAttribute.ATTR_ALIASED_FULLY_QUALIFIED_TABLE_NAME_AT_RUNTIME);
1505     }
1506 
1507     /**
1508      * This method can be used to initialize the generators before they will be called.
1509      * 
1510      * This method is called after all the setX methods, but before getNumberOfSubtasks(), getGeneratedJavaFiles, and
1511      * getGeneratedXmlFiles.
1512      *
1513      * @param warnings
1514      *            the warnings
1515      * @param progressCallback
1516      *            the progress callback
1517      */
1518     public abstract void calculateGenerators(List<String> warnings,
1519             ProgressCallback progressCallback);
1520 
1521     /**
1522      * This method should return a list of generated Java files related to this
1523      * table. This list could include various types of model classes, as well as
1524      * DAO classes.
1525      * 
1526      * @return the list of generated Java files for this table
1527      */
1528     public abstract List<GeneratedJavaFile> getGeneratedJavaFiles();
1529 
1530     /**
1531      * This method should return a list of generated XML files related to this
1532      * table. Most implementations will only return one file - the generated
1533      * SqlMap file.
1534      * 
1535      * @return the list of generated XML files for this table
1536      */
1537     public abstract List<GeneratedXmlFile> getGeneratedXmlFiles();
1538 
1539     /**
1540      * Denotes whether generated code is targeted for Java version 5.0 or
1541      * higher.
1542      * 
1543      * @return true if the generated code makes use of Java5 features
1544      */
1545     public abstract boolean isJava5Targeted();
1546 
1547     /**
1548      * This method should return the number of progress messages that will be
1549      * send during the generation phase.
1550      * 
1551      * @return the number of progress messages
1552      */
1553     public abstract int getGenerationSteps();
1554 
1555     /**
1556      * This method exists to give plugins the opportunity to replace the calculated rules if necessary.
1557      *
1558      * @param rules
1559      *            the new rules
1560      */
1561     public void setRules(Rules rules) {
1562         this.rules = rules;
1563     }
1564 
1565     /**
1566      * Gets the table configuration.
1567      *
1568      * @return the table configuration
1569      */
1570     public TableConfiguration getTableConfiguration() {
1571         return tableConfiguration;
1572     }
1573 
1574     /**
1575      * Sets the DAO implementation type.
1576      *
1577      * @param DAOImplementationType
1578      *            the new DAO implementation type
1579      */
1580     public void setDAOImplementationType(String DAOImplementationType) {
1581         internalAttributes.put(InternalAttribute.ATTR_DAO_IMPLEMENTATION_TYPE,
1582                 DAOImplementationType);
1583     }
1584 
1585     /**
1586      * Sets the DAO interface type.
1587      *
1588      * @param DAOInterfaceType
1589      *            the new DAO interface type
1590      */
1591     public void setDAOInterfaceType(String DAOInterfaceType) {
1592         internalAttributes.put(InternalAttribute.ATTR_DAO_INTERFACE_TYPE,
1593                 DAOInterfaceType);
1594     }
1595 
1596     /**
1597      * Sets the primary key type.
1598      *
1599      * @param primaryKeyType
1600      *            the new primary key type
1601      */
1602     public void setPrimaryKeyType(String primaryKeyType) {
1603         internalAttributes.put(InternalAttribute.ATTR_PRIMARY_KEY_TYPE,
1604                 primaryKeyType);
1605     }
1606 
1607     /**
1608      * Sets the base record type.
1609      *
1610      * @param baseRecordType
1611      *            the new base record type
1612      */
1613     public void setBaseRecordType(String baseRecordType) {
1614         internalAttributes.put(InternalAttribute.ATTR_BASE_RECORD_TYPE,
1615                 baseRecordType);
1616     }
1617 
1618     /**
1619      * Sets the record with blo bs type.
1620      *
1621      * @param recordWithBLOBsType
1622      *            the new record with blo bs type
1623      */
1624     public void setRecordWithBLOBsType(String recordWithBLOBsType) {
1625         internalAttributes.put(InternalAttribute.ATTR_RECORD_WITH_BLOBS_TYPE,
1626                 recordWithBLOBsType);
1627     }
1628 
1629     /**
1630      * Sets the example type.
1631      *
1632      * @param exampleType
1633      *            the new example type
1634      */
1635     public void setExampleType(String exampleType) {
1636         internalAttributes
1637                 .put(InternalAttribute.ATTR_EXAMPLE_TYPE, exampleType);
1638     }
1639 
1640     /**
1641      * Sets the ibatis2 sql map package.
1642      *
1643      * @param sqlMapPackage
1644      *            the new ibatis2 sql map package
1645      */
1646     public void setIbatis2SqlMapPackage(String sqlMapPackage) {
1647         internalAttributes.put(InternalAttribute.ATTR_IBATIS2_SQL_MAP_PACKAGE,
1648                 sqlMapPackage);
1649     }
1650 
1651     /**
1652      * Sets the ibatis2 sql map file name.
1653      *
1654      * @param sqlMapFileName
1655      *            the new ibatis2 sql map file name
1656      */
1657     public void setIbatis2SqlMapFileName(String sqlMapFileName) {
1658         internalAttributes.put(
1659                 InternalAttribute.ATTR_IBATIS2_SQL_MAP_FILE_NAME,
1660                 sqlMapFileName);
1661     }
1662 
1663     /**
1664      * Sets the ibatis2 sql map namespace.
1665      *
1666      * @param sqlMapNamespace
1667      *            the new ibatis2 sql map namespace
1668      */
1669     public void setIbatis2SqlMapNamespace(String sqlMapNamespace) {
1670         internalAttributes.put(
1671                 InternalAttribute.ATTR_IBATIS2_SQL_MAP_NAMESPACE,
1672                 sqlMapNamespace);
1673     }
1674     
1675     /**
1676      * Sets the my batis3 fallback sql map namespace.
1677      *
1678      * @param sqlMapNamespace
1679      *            the new my batis3 fallback sql map namespace
1680      */
1681     public void setMyBatis3FallbackSqlMapNamespace(String sqlMapNamespace) {
1682         internalAttributes.put(
1683                 InternalAttribute.ATTR_MYBATIS3_FALLBACK_SQL_MAP_NAMESPACE,
1684                 sqlMapNamespace);
1685     }
1686 
1687     /**
1688      * Sets the sql map fully qualified runtime table name.
1689      *
1690      * @param fullyQualifiedRuntimeTableName
1691      *            the new sql map fully qualified runtime table name
1692      */
1693     public void setSqlMapFullyQualifiedRuntimeTableName(
1694             String fullyQualifiedRuntimeTableName) {
1695         internalAttributes.put(
1696                 InternalAttribute.ATTR_FULLY_QUALIFIED_TABLE_NAME_AT_RUNTIME,
1697                 fullyQualifiedRuntimeTableName);
1698     }
1699 
1700     /**
1701      * Sets the sql map aliased fully qualified runtime table name.
1702      *
1703      * @param aliasedFullyQualifiedRuntimeTableName
1704      *            the new sql map aliased fully qualified runtime table name
1705      */
1706     public void setSqlMapAliasedFullyQualifiedRuntimeTableName(
1707             String aliasedFullyQualifiedRuntimeTableName) {
1708         internalAttributes
1709                 .put(
1710                         InternalAttribute.ATTR_ALIASED_FULLY_QUALIFIED_TABLE_NAME_AT_RUNTIME,
1711                         aliasedFullyQualifiedRuntimeTableName);
1712     }
1713 
1714     /**
1715      * Gets the my batis3 xml mapper package.
1716      *
1717      * @return the my batis3 xml mapper package
1718      */
1719     public String getMyBatis3XmlMapperPackage() {
1720         return internalAttributes
1721                 .get(InternalAttribute.ATTR_MYBATIS3_XML_MAPPER_PACKAGE);
1722     }
1723 
1724     /**
1725      * Sets the my batis3 xml mapper package.
1726      *
1727      * @param mybatis3XmlMapperPackage
1728      *            the new my batis3 xml mapper package
1729      */
1730     public void setMyBatis3XmlMapperPackage(String mybatis3XmlMapperPackage) {
1731         internalAttributes.put(
1732                 InternalAttribute.ATTR_MYBATIS3_XML_MAPPER_PACKAGE,
1733                 mybatis3XmlMapperPackage);
1734     }
1735 
1736     /**
1737      * Gets the my batis3 xml mapper file name.
1738      *
1739      * @return the my batis3 xml mapper file name
1740      */
1741     public String getMyBatis3XmlMapperFileName() {
1742         return internalAttributes
1743                 .get(InternalAttribute.ATTR_MYBATIS3_XML_MAPPER_FILE_NAME);
1744     }
1745 
1746     /**
1747      * Sets the my batis3 xml mapper file name.
1748      *
1749      * @param mybatis3XmlMapperFileName
1750      *            the new my batis3 xml mapper file name
1751      */
1752     public void setMyBatis3XmlMapperFileName(String mybatis3XmlMapperFileName) {
1753         internalAttributes.put(
1754                 InternalAttribute.ATTR_MYBATIS3_XML_MAPPER_FILE_NAME,
1755                 mybatis3XmlMapperFileName);
1756     }
1757 
1758     /**
1759      * Gets the my batis3 java mapper type.
1760      *
1761      * @return the my batis3 java mapper type
1762      */
1763     public String getMyBatis3JavaMapperType() {
1764         return internalAttributes
1765                 .get(InternalAttribute.ATTR_MYBATIS3_JAVA_MAPPER_TYPE);
1766     }
1767 
1768     /**
1769      * Sets the my batis3 java mapper type.
1770      *
1771      * @param mybatis3JavaMapperType
1772      *            the new my batis3 java mapper type
1773      */
1774     public void setMyBatis3JavaMapperType(String mybatis3JavaMapperType) {
1775         internalAttributes.put(
1776                 InternalAttribute.ATTR_MYBATIS3_JAVA_MAPPER_TYPE,
1777                 mybatis3JavaMapperType);
1778     }
1779 
1780     /**
1781      * Gets the my batis3 sql provider type.
1782      *
1783      * @return the my batis3 sql provider type
1784      */
1785     public String getMyBatis3SqlProviderType() {
1786         return internalAttributes
1787                 .get(InternalAttribute.ATTR_MYBATIS3_SQL_PROVIDER_TYPE);
1788     }
1789 
1790     /**
1791      * Sets the my batis3 sql provider type.
1792      *
1793      * @param mybatis3SqlProviderType
1794      *            the new my batis3 sql provider type
1795      */
1796     public void setMyBatis3SqlProviderType(String mybatis3SqlProviderType) {
1797         internalAttributes.put(
1798                 InternalAttribute.ATTR_MYBATIS3_SQL_PROVIDER_TYPE,
1799                 mybatis3SqlProviderType);
1800     }
1801     
1802     /**
1803      * Gets the target runtime.
1804      *
1805      * @return the target runtime
1806      */
1807     public TargetRuntime getTargetRuntime() {
1808         return targetRuntime;
1809     }
1810     
1811     /**
1812      * Checks if is immutable.
1813      *
1814      * @return true, if is immutable
1815      */
1816     public boolean isImmutable() {
1817         Properties properties;
1818         
1819         if (tableConfiguration.getProperties().containsKey(PropertyRegistry.ANY_IMMUTABLE)) {
1820             properties = tableConfiguration.getProperties();
1821         } else {
1822             properties = context.getJavaModelGeneratorConfiguration().getProperties();
1823         }
1824         
1825         return isTrue(properties.getProperty(PropertyRegistry.ANY_IMMUTABLE));
1826     }
1827     
1828     /**
1829      * Checks if is constructor based.
1830      *
1831      * @return true, if is constructor based
1832      */
1833     public boolean isConstructorBased() {
1834         if (isImmutable()) {
1835             return true;
1836         }
1837         
1838         Properties properties;
1839         
1840         if (tableConfiguration.getProperties().containsKey(PropertyRegistry.ANY_CONSTRUCTOR_BASED)) {
1841             properties = tableConfiguration.getProperties();
1842         } else {
1843             properties = context.getJavaModelGeneratorConfiguration().getProperties();
1844         }
1845         
1846         return isTrue(properties.getProperty(PropertyRegistry.ANY_CONSTRUCTOR_BASED));
1847     }
1848 
1849     /**
1850      * Should return true if an XML generator is required for this table. This method will be called during validation
1851      * of the configuration, so it should not rely on database introspection. This method simply tells the validator if
1852      * an XML configuration is normally required for this implementation.
1853      *
1854      * @return true, if successful
1855      */
1856     public abstract boolean requiresXMLGenerator();
1857 
1858     /**
1859      * Gets the context.
1860      *
1861      * @return the context
1862      */
1863     public Context getContext() {
1864         return context;
1865     }
1866 
1867 	public String getRemarks() {
1868 		return remarks;
1869 	}
1870 
1871 	public void setRemarks(String remarks) {
1872 		this.remarks = remarks;
1873 	}
1874 
1875 	public String getTableType() {
1876 		return tableType;
1877 	}
1878 
1879 	public void setTableType(String tableType) {
1880 		this.tableType = tableType;
1881 	}
1882 }