Query query = em.createNamedQuery("findMe"); Session session = em.unwrap(JpaEntityManager.class).getActiveSession(); DatabaseQuery databaseQuery = ((EJBQueryImpl)query).getDatabaseQuery(); databaseQuery.prepareCall(session, new DatabaseRecord()); String sqlString = databaseQuery.getSQLString();
DatabaseRecord recordWithValues= new DatabaseRecord(); recordWithValues.add(new DatabaseField("param1"), "someValue"); String sqlStringWithArgs = databaseQuery.getTranslatedSQLString(session, recordWithValues);
/** * Create a new row/record for the object builder. * This allows subclasses to define different record types. */ public AbstractRecord createRecord(int size, AbstractSession session) { return new DatabaseRecord(size); }
/** * ADVANCED: * This method is used to access the changes of the fields in a transformation mapping. */ public Record getRecord() { if (rowCollection == null) { this.rowCollection = new DatabaseRecord(); } return rowCollection; }
/** * Create a new row/record for the object builder. * This allows subclasses to define different record types. */ public AbstractRecord createRecord(AbstractSession session) { return new DatabaseRecord(); }
/** * INTERNAL: * Create a row that contains source relation fields with values extracted from the source object. */ public AbstractRecord buildRelationTableSourceRow(Object sourceObject, AbstractSession session, ForeignReferenceMapping mapping) { AbstractRecord databaseRow = new DatabaseRecord(); return addRelationTableSourceRow(sourceObject, session, databaseRow, mapping); }
/** * INTERNAL: * Add a field - value pair for LOB field into the context. */ public void addContext(DatabaseField field, Object value) { if (this.contexts == null) { this.contexts = new DatabaseRecord(2); } this.contexts.add(field, value); this.isBatchExecutionSupported = false; }
/** * INTERNAL: * Add a field - value pair for LOB field into the context. */ public void addContext(DatabaseField field, Object value) { if (this.contexts == null) { this.contexts = new DatabaseRecord(2); } this.contexts.add(field, value); this.isBatchExecutionSupported = false; }
/** * INTERNAL: Generates the stored procedure for this query. A new row * will be used for the check prepare. */ protected StoredProcedureDefinition generateStoredProcedure(DatabaseQuery query, List fields, String name) { return generateStoredProcedure(query, fields, new DatabaseRecord(), name); }
/** * INTERNAL: * Create a row that contains source relation fields with values extracted from the source row. */ public AbstractRecord buildRelationTableSourceRow(AbstractRecord sourceRow) { AbstractRecord databaseRow = new DatabaseRecord(); return addRelationTableSourceRow(sourceRow, databaseRow); }
/** * INTERNAL: * Create a row that contains source relation fields with values extracted from the source object. */ public AbstractRecord buildRelationTableSourceRow(Object sourceObject, AbstractSession session, ForeignReferenceMapping mapping) { AbstractRecord databaseRow = new DatabaseRecord(); return addRelationTableSourceRow(sourceObject, session, databaseRow, mapping); }
/** * INTERNAL: * Create a row that contains source relation fields with values extracted from the source object. */ public AbstractRecord buildRelationTableSourceRow(Object sourceObject, AbstractSession session, ForeignReferenceMapping mapping) { AbstractRecord databaseRow = new DatabaseRecord(); return addRelationTableSourceRow(sourceObject, session, databaseRow, mapping); }
/** * INTERNAL: * Add a field - value pair for LOB field into the context. */ public void addContext(DatabaseField field, Object value) { if (contexts == null) { contexts = new DatabaseRecord(2); } contexts.add(field, value); }
/** * INTERNAL: */ protected AbstractRecord getMappedTranslationRow(Object changedObj, UnitOfWorkImpl uow) { AbstractRecord translationRow = new DatabaseRecord(); Iterator<Map.Entry<DatabaseField, DatabaseField>> it = m_mappedQueryKeyFields.entrySet().iterator(); while(it.hasNext()) { Map.Entry<DatabaseField, DatabaseField> entry = it.next(); Object value = m_descriptor.getObjectBuilder().extractValueFromObjectForField(changedObj, entry.getValue(), uow); translationRow.add(entry.getKey(), value); } return translationRow; }
/** * INTERNAL: */ protected AbstractRecord createModifyRowForAddTargetQuery() { AbstractRecord modifyRow = new DatabaseRecord(); containerPolicy.addFieldsForMapKey(modifyRow); if(listOrderField != null) { modifyRow.add(listOrderField, null); } return modifyRow; }
/** * INTERNAL: */ protected AbstractRecord createModifyRowForAddTargetQuery() { AbstractRecord modifyRow = new DatabaseRecord(); containerPolicy.addFieldsForMapKey(modifyRow); if(listOrderField != null) { modifyRow.add(listOrderField, null); } return modifyRow; }
/** * INTERNAL: */ protected AbstractRecord createModifyRowForAddTargetQuery() { AbstractRecord modifyRow = new DatabaseRecord(); containerPolicy.addFieldsForMapKey(modifyRow); if(listOrderField != null) { modifyRow.add(listOrderField, null); } return modifyRow; }
/** * ADVANCED: * Set all of the objects from the given Expression to be invalid in the cache. */ public void invalidateObjects(Expression selectionCriteria) { invalidateObjects(selectionCriteria, selectionCriteria.getBuilder().getQueryClass(), new DatabaseRecord(0), true); }
/** * ADVANCED: * Set all of the objects from the given Expression to be invalid in the cache. */ public void invalidateObjects(Expression selectionCriteria) { invalidateObjects(selectionCriteria, selectionCriteria.getBuilder().getQueryClass(), new DatabaseRecord(0), true); }
/** * INTERNAL: Generates the delete stored procedure for this descriptor */ protected StoredProcedureDefinition generateDeleteStoredProcedure(ClassDescriptor descriptor) { DeleteObjectQuery deleteQuery = new DeleteObjectQuery(); deleteQuery.setDescriptor(descriptor); deleteQuery.setModifyRow(new DatabaseRecord()); return this.generateObjectStoredProcedure(deleteQuery, descriptor.getPrimaryKeyFields(), "DEL_"); }