if(entity.getDataMap()!=null && entity.getDataMap().isQuotingSQLIdentifiers()){
status= true;
} else {
status = false;
}
QuotingStrategy context = getQuotingStrategy(status);
// must move generated to the front...
List<DbAttribute> pkList = new ArrayList<DbAttribute>(entity.getPrimaryKeys());
Collections.sort(pkList, new PKComparator());
Iterator<DbAttribute> pkit = pkList.iterator();
if (pkit.hasNext()) {
sqlBuffer.append(", PRIMARY KEY (");
boolean firstPk = true;
while (pkit.hasNext()) {
if (firstPk)
firstPk = false;
else
sqlBuffer.append(", ");
DbAttribute at = pkit.next();
sqlBuffer.append(context.quoteString(at.getName()));
}
sqlBuffer.append(')');
}
// if FK constraints are supported, we must add indices to all FKs
// Note that according to MySQL docs, FK indexes are created automatically when
// constraint is defined, starting at MySQL 4.1.2
if (supportsFkConstraints()) {
for (Relationship r : entity.getRelationships()) {
DbRelationship relationship = (DbRelationship) r;
if (relationship.getJoins().size() > 0
&& relationship.isToPK()
&& !relationship.isToDependentPK()) {
sqlBuffer.append(", KEY (");
Iterator<DbAttribute> columns = relationship
.getSourceAttributes()
.iterator();
DbAttribute column = columns.next();
sqlBuffer.append(context.quoteString(column.getName()));
while (columns.hasNext()) {
column = columns.next();
sqlBuffer.append(", ").append( context.quoteString(column.getName()));
}
sqlBuffer.append(")");
}
}