use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class Statement method generateColumnText.
/**
* Generates the column text for field <code>desc</code>.
* The column has to be associated to the corresponding query table
* from the list <code>tableList</code>.
* For fields mapped to multiple columns choose one column to be included,
* as all mapped columns should have the same value.
*
* @param desc Local field descriptor to be included in the constraint text.
* @param thePlan Query plan corresponding to <code>desc</code>.
* @param sb String buffer taking the resulting text.
*/
protected void generateColumnText(LocalFieldDesc desc, QueryPlan thePlan, StringBuffer sb) {
QueryTable table = null;
ColumnElement column = null;
Iterator iter = desc.getColumnElements();
while (iter.hasNext() && table == null) {
column = (ColumnElement) iter.next();
// from the query plan to find the table matching the column.
if (action == QueryPlan.ACT_SELECT) {
table = thePlan.findQueryTable(column.getDeclaringTable());
} else {
table = findQueryTable(column.getDeclaringTable());
}
}
if (table == null) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.configuration.fieldnotable", desc.getName()));
}
// Qualify the column with the table index.
if (action == QueryPlan.ACT_SELECT) {
// NOI18N
sb.append("t").append(table.getTableIndex()).append(".");
}
appendQuotedText(sb, column.getName().getName());
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class TransactionImpl method begin.
/**
* Begin a transaction in managed environment
*/
public void begin(javax.transaction.Transaction t) {
persistenceManager.acquireExclusiveLock();
try {
beginInternal();
try {
jta = t;
EJBHelper.registerSynchronization(jta, this);
} catch (Exception e) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, "transaction.transactionimpl.begin.registersynchfailed"), // NOI18N
e);
}
txType = CMT;
} finally {
persistenceManager.releaseExclusiveLock();
}
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class TransactionImpl method begin.
//
// ----- Methods from javax.transaction.Transaction interface ------
//
/**
* Begin a transaction.
*/
public void begin() {
persistenceManager.acquireExclusiveLock();
try {
// Check and set status...
beginInternal();
// BMT with JDO Transaction
if (EJBHelper.isManaged()) {
txType = BMT_JDO;
try {
TransactionManager tm = EJBHelper.getLocalTransactionManager();
tm.begin();
jta = tm.getTransaction();
EJBHelper.registerSynchronization(jta, this);
pmFactory.registerPersistenceManager(persistenceManager, jta);
} catch (JDOException e) {
// re-throw it.
throw e;
} catch (Exception e) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, "transaction.transactionimpl.begin.failedlocaltx"), // NOI18N
e);
}
} else {
txType = NON_MGD;
}
} finally {
persistenceManager.releaseExclusiveLock();
}
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class ForeignFieldDesc method createObjectId.
/**
* Constructs the oid of a related instance. If called by {@link
* SQLStateManager#updateTrackedFields}, the new value for the
* local field <code>fieldDesc</code> is not yet set and passed as
* parameter <code>value</code>. If called for navigation by
* {@link SQLStateManager#populateForeignField}, values of updated
* local fields must be retrieved from the before image. In both
* cases, the actual call to this method is in {@link
* SQLStateManager#getObjectById}.<p>
* For tracked field usage, see
* {@link SQLStateManager#setForeignKey} and
* {@link SQLStateManager#updateTrackedFields}.
* For navigation usage, see
* {@link SQLStateManager#realizeForeignField}.
*
* @param sm State manager on the local side.
* @param fieldDesc Local field being set.
* @param value New value of the field being set.
* @return The object id for the related instance. This id is used
* to lookup the instance from the persistence manager cache. The
* construced oid is invalid, if one of the oid fields is
* null. In this case the returned value is null.
*/
public Object createObjectId(SQLStateManager sm, LocalFieldDesc fieldDesc, Object value) {
assert isMappedToPk();
Class oidClass = foreignConfig.getOidClass();
Object oid = null;
try {
oid = oidClass.newInstance();
} catch (Exception e) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, "core.statemanager.cantnewoid", oidClass.getName()), // NOI18N
e);
}
Field[] keyFields = foreignConfig.getKeyFields();
String[] keyFieldNames = foreignConfig.getKeyFieldNames();
for (int i = 0; i < keyFields.length && oid != null; i++) {
Field keyField = keyFields[i];
for (int j = 0; j < foreignFields.size() && oid != null; j++) {
LocalFieldDesc fa = (LocalFieldDesc) foreignFields.get(j);
if (fa.getName().compareTo(keyFieldNames[i]) == 0) {
LocalFieldDesc la = (LocalFieldDesc) localFields.get(j);
Object keyFieldValue = null;
if (la == fieldDesc) {
keyFieldValue = value;
} else if (sm.getSetMaskBit(la.absoluteID) && !sm.getSetMaskBit(absoluteID)) {
keyFieldValue = la.getValue(sm.getBeforeImage());
} else {
keyFieldValue = la.getValue(sm);
}
if (keyFieldValue != null) {
try {
// We need to convert the keyFieldValue to the proper type before
// setting it.
keyField.set(oid, fa.convertValue(keyFieldValue, sm));
} catch (IllegalAccessException e) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, "core.statemanager.cantsetkeyfield", keyField.getName()), // NOI18N
e);
}
} else {
oid = null;
}
}
}
}
return oid;
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException 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));
}
}
}
Aggregations