/** * INTERNAL: * Return the lowlevel database accessor. * The database accesor is used for direct database access. * If sessionBroker is used, the right accessor for this * broker will be returned based on the session name. */ public Accessor getAccessor(String sessionName) { return getAccessor(); }
/** * INTERNAL: * Return the lowlevel database accessor. * The database accesor is used for direct database access. * If sessionBroker is used, the right accessor for this * broker will be returned. */ public Accessor getAccessor(Class domainClass) { return getAccessor(); }
/** * PUBLIC: * Return if this session is connected to the database. */ public boolean isConnected() { if (getAccessor() == null) { return false; } return getAccessor().isConnected(); }
/** * INTERNAL: * The uow does not store a local accessor but shares its parents. */ public Accessor getAccessor() { return getParent().getAccessor(); }
/** * INTERNAL: * The uow does not store a local accessor but shares its parents. */ public Accessor getAccessor(String sessionName) { return getParent().getAccessor(sessionName); }
/** * Return the appropriate accessor. * Assume we are dealing with a JDBC accessor. */ protected DatabaseAccessor getAccessor() { return (DatabaseAccessor)getSession().getAccessor(); }
/** * INTERNAL: * The uow does not store a local accessor but shares its parents. */ public Accessor getAccessor(Class domainClass) { return getParent().getAccessor(domainClass); }
/** * INTERNAL: * This method notifies the accessor that a particular sets of writes has * completed. This notification can be used for such thing as flushing the * batch mechanism */ public void writesCompleted() { getAccessor().writesCompleted(this); }
/** * INTERNAL: * This method is used to get all the database tables and add them into a vector. */ public void initializeTables(AbstractSession session) { Vector result = session.getAccessor().getTableInfo(null, null, null, null, session); for (Enumeration resultEnum = result.elements(); resultEnum.hasMoreElements();) { AbstractRecord row = (AbstractRecord)resultEnum.nextElement(); tables.addElement(row.get("TABLE_NAME")); } }
/** * INTERNAL: * Return the read or write connection depending on the transaction state. */ public Accessor getAccessor() { if (isInTransaction()) { return getWriteConnection(); } return super.getAccessor(); }
/** * INTERNAL: * Called by beginTransaction() to start a transaction. * This starts a real database transaction. */ protected void basicBeginTransaction() throws DatabaseException { try { getAccessor().beginTransaction(this); } catch (RuntimeException exception) { handleException(exception); } }
/** * INTERNAL: * Called by commitTransaction() to commit a transaction. * This commits the active transaction. */ protected void basicCommitTransaction() throws DatabaseException { try { getAccessor().commitTransaction(this); } catch (RuntimeException exception) { handleException(exception); } }
/** * INTERNAL: * Called by rollbackTransaction() to rollback a transaction. * This rollsback the active transaction. */ protected void basicRollbackTransaction() throws DatabaseException { try { getAccessor().rollbackTransaction(this); } catch (RuntimeException exception) { handleException(exception); } }
/** * Print the connection status with the session. */ public String toString() { StringWriter writer = new StringWriter(); writer.write(getSessionTypeString() + "(" + Helper.cr() + "\t" + getAccessor() + Helper.cr() + "\t" + getDatasourcePlatform() + ")"); return writer.toString(); }
/** * To check that tables and fields are present in database */ protected void checkDatabase(AbstractSession session) { if (session.getIntegrityChecker().shouldCheckDatabase()) { for (Enumeration enumTable = getTables().elements(); enumTable.hasMoreElements();) { DatabaseTable table = (DatabaseTable)enumTable.nextElement(); if (session.getIntegrityChecker().checkTable(table, session)) { // To load the fields of database into a vector Vector databaseFields = new Vector(); Vector result = session.getAccessor().getColumnInfo(null, null, table.getName(), null, session); for (Enumeration resultEnum = result.elements(); resultEnum.hasMoreElements();) { AbstractRecord row = (AbstractRecord)resultEnum.nextElement(); databaseFields.addElement(row.get("COLUMN_NAME")); } // To check that the fields of descriptor are present in the database. for (Enumeration row = getFields().elements(); row.hasMoreElements();) { DatabaseField field = (DatabaseField)row.nextElement(); if (field.getTable().equals(table) && (!databaseFields.contains(field.getName()))) { session.getIntegrityChecker().handleError(DescriptorException.fieldIsNotPresentInDatabase(this, table.getName(), field.getName())); } } } else { session.getIntegrityChecker().handleError(DescriptorException.tableIsNotPresentInDatabase(this)); } } } }
/** * INTERNAL: * Override From session. Get the accessor based on the query, and execute call, * this is here for session broker. */ public Object executeCall(Call call, AbstractRecord translationRow, DatabaseQuery query) throws DatabaseException { Accessor accessor; if (query.getSessionName() == null) { accessor = query.getSession().getAccessor(query.getReferenceClass()); } else { accessor = query.getSession().getAccessor(query.getSessionName()); } query.setAccessor(accessor); try { return query.getAccessor().executeCall(call, translationRow, this); } finally { if (call.isFinished()) { query.setAccessor(null); } } }
/** * INTERNAL: * Overridden by subclasses that do more than just execute the call. * Executes the call directly on this session and does not check which * session it should have executed on. */ public Object executeCall(Call call, AbstractRecord translationRow, DatabaseQuery query) throws DatabaseException { //** sequencing refactoring if (query.getAccessor() == null) { query.setAccessor(getAccessor()); } try { return query.getAccessor().executeCall(call, translationRow, this); } finally { if (call.isFinished()) { query.setAccessor(null); } } }
accessor = writeSession.getAccessor(); Hashtable localSequences = (Hashtable)accessorToPreallocated.get(accessor); if (localSequences == null) {
executionSession.getAccessor().flushSelectCalls(executionSession); return returnedRowCount;
executionSession.getAccessor().flushSelectCalls(executionSession);