Search in sources :

Example 1 with JDOFatalDataStoreException

use of com.sun.jdo.api.persistence.support.JDOFatalDataStoreException in project Payara by payara.

the class SelectStatement method generateForUpdateClause.

private StringBuffer generateForUpdateClause(boolean updateLockRequired) {
    StringBuffer forUpdateClause = new StringBuffer();
    if (updateLockRequired) {
        // Check if vendor actually supports updatelock
        if (!vendorType.isUpdateLockSupported()) {
            // But vendor is not supporting it. Do not allow user to proceed
            throw new JDOFatalDataStoreException(I18NHelper.getMessage(messages, // NOI18N
            "sqlstore.selectstatement.noupdatelocksupport"));
        }
        // generating the ForUpdate Clause
        String vendorForUpdate = vendorType.getForUpdate().trim();
        boolean vendorHasForUpdateClause = (vendorForUpdate.length() != 0);
        if (vendorHasForUpdateClause) {
            forUpdateClause.append(" ").append(vendorForUpdate).append(" ");
            if (vendorType.isLockColumnListSupported()) {
                for (int i = 0; i < tableList.size(); i++) {
                    QueryTable queryTable = (QueryTable) tableList.get(i);
                    if (isUpdateLockRequired(queryTable)) {
                        TableDesc tableDesc = queryTable.getTableDesc();
                        // Get the first column of primary key
                        ColumnElement ce = (ColumnElement) tableDesc.getKey().getColumns().get(0);
                        // NOI18N
                        forUpdateClause.append("t").append(i).append(".");
                        appendQuotedText(forUpdateClause, ce.getName().getName());
                        // NOI18N
                        forUpdateClause.append(", ");
                    }
                }
                // Remove trailing ", "
                forUpdateClause.delete(forUpdateClause.length() - 2, forUpdateClause.length());
            }
        }
    }
    return forUpdateClause;
}
Also used : TableDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.TableDesc) ColumnElement(org.netbeans.modules.dbschema.ColumnElement) JDOFatalDataStoreException(com.sun.jdo.api.persistence.support.JDOFatalDataStoreException)

Example 2 with JDOFatalDataStoreException

use of com.sun.jdo.api.persistence.support.JDOFatalDataStoreException in project Payara by payara.

the class JDOEJB11HelperImpl method readSerializableObjectFromByteArray.

/**
 * Constructs a Serializable object from byteArray. It is expected that
 * byteArray was constructed using a previous call to writeSerializableObjectToByteArray
 * @param byteArray Array of byte obtained from a call to writeSerializableObjectToByteArray
 * @return A Serializable object contructed from byteArray
 * @see #writeSerializableObjectToByteArray(Serializable)
 */
public Serializable readSerializableObjectFromByteArray(byte[] byteArray) {
    Serializable serializableObject = null;
    if (byteArray != null) {
        ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
        HelperObjectInputStream ois = null;
        // 
        // Take the current class loader to resolve the class to be deserialized.
        // 
        ClassLoader cl = this.getClass().getClassLoader();
        try {
            ois = new HelperObjectInputStream(bis, cl);
            serializableObject = (Serializable) ois.readObject();
        } catch (ClassNotFoundException e) {
            throw new JDOFatalDataStoreException(I18NHelper.getMessage(messages, "EXC_CNFReadSerializableObject"), // NOI18N
            e);
        } catch (java.io.IOException e) {
            throw new JDOFatalDataStoreException(I18NHelper.getMessage(messages, "EXC_IOReadSerializableObject"), // NOI18N
            e);
        }
    }
    return serializableObject;
}
Also used : java.io(java.io) JDOFatalDataStoreException(com.sun.jdo.api.persistence.support.JDOFatalDataStoreException)

Aggregations

JDOFatalDataStoreException (com.sun.jdo.api.persistence.support.JDOFatalDataStoreException)2 TableDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.TableDesc)1 java.io (java.io)1 ColumnElement (org.netbeans.modules.dbschema.ColumnElement)1