use of com.sun.jdo.spi.persistence.support.sqlstore.model.ClassDesc in project Payara by payara.
the class QueryPlan method addQueryTable.
/**
* Identifies a database table which will become part of this
* query plan. We will build a QueryTable object describing its
* use and return it.
*
* Note: No join is constructed at this point for the table added.
*
* @param tableElement Identifies which table is being added.
* @param persistenceConfig
* If we are adding a foreign table the persistenceConfig parameter
* holds the PersistenceConfig for the foreign Persistence Class.
*/
public QueryTable addQueryTable(TableElement tableElement, ClassDesc persistenceConfig) {
ClassDesc _config = (persistenceConfig == null) ? this.config : persistenceConfig;
TableDesc tableDesc = _config.findTableDesc(tableElement);
if (tableDesc == null) {
if (tableElement != null) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.configuration.classnotmappedtotable", _config.getPersistenceCapableClass().getName(), tableElement.getName().getName()));
} else {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.configuration.classnotmapped", _config.getPersistenceCapableClass().getName()));
}
}
return addQueryTable(tableDesc);
}
use of com.sun.jdo.spi.persistence.support.sqlstore.model.ClassDesc in project Payara by payara.
the class UpdateObjectDescImpl method setObjectInfo.
/**
* We send the AfterImage for updates and inserts
* but for updates it will only hold values for updated attributes (unless
* the class is configured to send the whole AfterImage, also we'll let the
* concurrency interface affect the sent AfterImage (and the sent
* BeforeImage)). For deletes the AfterImage will be NIL, for inserts the
* BeforeImage will be NIL. For deletes the BeforeImage will contain values
* for all key attributes. Also for deletes and updates we'll send the
* HiddenValues array from the paladin (although we can set to NIL any
* values in the array not needed by this particular update).
*
* UpdatedAttributes will contain indexes into the PersistentDesc.Attributes
* array for new or updated values.
*
* Initially we'll probably just send the whole BeforeImage and AfterImage
* (except that we won't have an AfterImage for Deletes and we won't have
* a BeforeImage for updates).
*/
public void setObjectInfo(StateManager biStateManager, StateManager aiStateManager, int action) {
this.beforeImage = (SQLStateManager) biStateManager;
this.afterImage = (SQLStateManager) aiStateManager;
ClassDesc config = (ClassDesc) afterImage.getPersistenceConfig();
updateAction = action;
this.afterHiddenValues = afterImage.hiddenValues;
if (beforeImage != null) {
this.beforeHiddenValues = beforeImage.hiddenValues;
}
// This pass through attributes we are only going to look at local attributes.
// These are attributes that are stored in this object and are not references
// to other persistent objects.
boolean debug = logger.isLoggable(Logger.FINER);
for (int i = 0; i < config.fields.size(); i++) {
FieldDesc f = (FieldDesc) config.fields.get(i);
LocalFieldDesc lf = null;
boolean updated = false;
if (f instanceof LocalFieldDesc) {
lf = (LocalFieldDesc) f;
} else {
continue;
}
if ((updateAction == LOG_DESTROY) || ((lf.sqlProperties & FieldDesc.PROP_RECORD_ON_UPDATE) > 0)) {
continue;
} else if (lf.absoluteID < 0) {
if ((beforeImage == null) || (beforeImage.getHiddenValue(lf.absoluteID) != afterImage.getHiddenValue(lf.absoluteID))) {
updated = true;
}
} else if (lf.getType().isPrimitive() || String.class == lf.getType() || java.util.Date.class == lf.getType()) {
Object afterVal = lf.getValue(afterImage);
Object beforeVal = null;
if (beforeImage != null) {
beforeVal = lf.getValue(beforeImage);
}
if ((beforeVal != null) && (afterVal != null)) {
if (!beforeVal.equals(afterVal)) {
updated = true;
}
} else {
updated = true;
}
} else {
// What else??
}
if (updated) {
if (debug) {
// NOI18N
logger.finer("sqlstore.sql.updateobjdescimpl.updated", f.getName());
}
updatedFields.add(lf);
}
}
if (concurrency != null) {
concurrency.commit(this, beforeImage, afterImage, updateAction);
}
}
Aggregations