use of org.netbeans.modules.dbschema.TableElement in project Payara by payara.
the class ClassDesc method initializeJoinTables.
private void initializeJoinTables() {
Iterator iter = foreignFields.iterator();
while (iter.hasNext()) {
ForeignFieldDesc ff = (ForeignFieldDesc) iter.next();
if (ff.useJoinTable()) {
TableElement joinTable = ((ColumnElement) ff.assocLocalColumns.get(0)).getDeclaringTable();
TableDesc joinTableDesc = findTableDesc(joinTable);
if (joinTableDesc == null) {
joinTableDesc = new TableDesc(joinTable);
// Mark this table as a join table
joinTableDesc.setJoinTable(true);
addTableDesc(joinTableDesc);
}
}
}
}
use of org.netbeans.modules.dbschema.TableElement in project Payara by payara.
the class ForeignFieldDesc method initializeFieldLists.
/**
* Initialize the field lists based on column list information.
*/
private void initializeFieldLists() {
ClassDesc theConfig = classDesc;
for (int i = 0; i < 4; i++) {
ArrayList fields = null;
ArrayList columns = null;
switch(i) {
case 0:
columns = localColumns;
fields = getLocalFields();
break;
case 1:
columns = assocLocalColumns;
fields = getAssocLocalFields();
break;
case 2:
columns = assocForeignColumns;
fields = getAssocForeignFields();
break;
case 3:
columns = foreignColumns;
fields = getForeignFields();
theConfig = foreignConfig;
break;
}
if (columns == null)
continue;
for (int j = 0; j < columns.size(); j++) {
ColumnElement ce = (ColumnElement) columns.get(j);
TableElement te = ce.getDeclaringTable();
if (te == null) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.configuration.columnnotable"));
}
fields.add(theConfig.getLocalFieldDesc(ce));
}
}
}
use of org.netbeans.modules.dbschema.TableElement in project Payara by payara.
the class UpdateQueryPlan method addColumn.
/**
* Specifies an field the data for which needs to be updated,
* and the mapped columns for which therefor need to be updated.
* For update queries the column will be put in the set lists,
* and for insert queries the column will be put into the
* insert values lists.
*
* @param fieldDesc Updated field corresponding to a column in the database.
* @param value New value.
*/
private void addColumn(LocalFieldDesc fieldDesc, Object value) {
// Ignore secondary tracked fields.
if ((fieldDesc.sqlProperties & FieldDesc.PROP_SECONDARY_TRACKED_FIELD) > 0) {
return;
}
for (Iterator iter = fieldDesc.getColumnElements(); iter.hasNext(); ) {
ColumnElement columnElement = (ColumnElement) iter.next();
TableElement tableElement = columnElement.getDeclaringTable();
if (tableElement == null) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.configuration.fieldnotable", fieldDesc.getName()));
}
QueryTable t = findQueryTable(tableElement);
UpdateStatement s = null;
if (t == null) {
t = addQueryTable(tableElement, null);
s = (UpdateStatement) addStatement(t);
} else {
s = (UpdateStatement) getStatement(t);
}
if (fieldDesc.isVersion() && action == ACT_UPDATE) {
// For update, version columns will be flagged specially.
s.addVersionColumn(columnElement);
} else {
s.addColumn(columnElement, value);
}
}
}
Aggregations