private Type getType(QName entity, boolean isAttribute, boolean isIndividual) { final XPathNodeWrapper currentNodeWrapper = getCurrentNodeWrapper(); final ClassDescriptor classDescriptor = currentNodeWrapper == null ? null : currentNodeWrapper.getClassDescriptor(); if (classDescriptor != null) { if (currentNodeWrapper.name.equals(entity)) { final Type containerType = getContainerType(isIndividual); return containerType != null ? containerType : classDescriptor.getJavaClass(); } else { final EntityType entityType = currentNodeWrapper.getEntitiesTypesMap(isAttribute).get(entity.getLocalPart()); return entityType == null ? null : entityType.type; } } return null; }
/** * Return the domain class associated with this query. */ public Class getReferenceClass() { if (this.object == null) { if (this.descriptor != null) { return this.descriptor.getJavaClass(); } return null; } return this.object.getClass(); }
/** * INTERNAL: * Convenience method to return true if the java class from this descriptor is abstract. */ protected boolean isAbstract() { return java.lang.reflect.Modifier.isAbstract(getJavaClass().getModifiers()); }
/** Returns the type of the class corresponding to the specified abstract * schema type. */ public Object resolveSchema(String schemaName) { ClassDescriptor descriptor = session.getDescriptorForAlias(schemaName); return (descriptor != null) ? descriptor.getJavaClass() : null; }
public CommitOrderDependencyNode nodeFor(Class c) { for (Enumeration e = nodes.elements(); e.hasMoreElements();) { CommitOrderDependencyNode n = (CommitOrderDependencyNode)e.nextElement(); if (n.getDescriptor().getJavaClass() == c) { return n; } } return null; }
public CommitOrderDependencyNode nodeFor(Class c) { for (Enumeration e = nodes.elements(); e.hasMoreElements();) { CommitOrderDependencyNode n = (CommitOrderDependencyNode)e.nextElement(); if (n.getDescriptor().getJavaClass() == c) { return n; } } return null; }
/** * {@inheritDoc} */ @Override public void visit(EntityTypeLiteral expression) { String entityTypeName = expression.getEntityTypeName(); ClassDescriptor descriptor = queryContext.getDescriptor(entityTypeName); type = descriptor.getJavaClass(); }
/** * INTERNAL: * Returns value of the abstract class indicator for the Java class. */ protected Object getClassIndicatorValue() { return getClassIndicatorValue(getDescriptor().getJavaClass()); }
/** * INTERNAL: * initialize the Policy */ public void initialize(AbstractSession session, ClassDescriptor descriptor) { //3934266 If changePolicy is ObjectChangeTrackingPolicy or AttributeChangeTrackingPolicy, the class represented //by the descriptor must implement ChangeTracker interface. Otherwise throw an exception. Class javaClass = descriptor.getJavaClass(); if (!ChangeTracker.class.isAssignableFrom(javaClass)) { session.getIntegrityChecker().handleError(DescriptorException.needToImplementChangeTracker(descriptor)); } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ protected void prepare() { super.prepare(); if (this.name == null) { this.name = "insert" + this.descriptor.getJavaClass().getSimpleName(); } getQueryMechanism().prepareInsertObject(); }
public static QueryException distinctCountOnOuterJoinedCompositePK( ClassDescriptor descr, DatabaseQuery query) { Object[] args = { descr.getJavaClass().getName(), descr.toString() }; QueryException queryException = new QueryException( ExceptionMessageGenerator.buildMessage( QueryException.class, DISTINCT_COUNT_ON_OUTER_JOINED_COMPOSITE_PK, args), query); queryException.setErrorCode(DISTINCT_COUNT_ON_OUTER_JOINED_COMPOSITE_PK); return queryException; }
public static QueryException distinctCountOnOuterJoinedCompositePK( ClassDescriptor descr, DatabaseQuery query) { Object[] args = { descr.getJavaClass().getName(), descr.toString() }; QueryException queryException = new QueryException( ExceptionMessageGenerator.buildMessage( QueryException.class, DISTINCT_COUNT_ON_OUTER_JOINED_COMPOSITE_PK, args), query); queryException.setErrorCode(DISTINCT_COUNT_ON_OUTER_JOINED_COMPOSITE_PK); return queryException; }
/** * {@inheritDoc} */ @Override public void visit(IdentificationVariable expression) { ClassDescriptor descriptor = queryContext.getDescriptor(expression.getVariableName()); queryExpression = queryContext.getBaseExpression(); queryExpression = new ConstantExpression(descriptor.getJavaClass(), queryExpression); }
public static DescriptorException mustBeReadOnlyMappingWhenStoredInCache(DatabaseMapping mapping) { Object[] args = { mapping.getDescriptor().getJavaClass() }; DescriptorException descriptorException = new DescriptorException(ExceptionMessageGenerator.buildMessage(DescriptorException.class, LOCK_MAPPING_MUST_BE_READONLY, args), mapping); descriptorException.setErrorCode(LOCK_MAPPING_MUST_BE_READONLY); return descriptorException; }
/** * INTERNAL: * Return a minimal time increment supported by the platform. */ public long getMinimumTimeIncrement(AbstractSession session) { AbstractSession readSession = session.getSessionForClass(getDescriptor().getJavaClass()); while (readSession.isUnitOfWork()) { readSession = ((UnitOfWorkImpl)readSession).getParent().getSessionForClass(getDescriptor().getJavaClass()); } return readSession.getPlatform().minimumTimeIncrement(); }
public static DescriptorException mappingCanNotBeReadOnly(DatabaseMapping mapping) { Object[] args = { mapping.getDescriptor().getJavaClass() }; DescriptorException descriptorException = new DescriptorException(ExceptionMessageGenerator.buildMessage(DescriptorException.class, LOCK_MAPPING_CANNOT_BE_READONLY, args), mapping); descriptorException.setErrorCode(LOCK_MAPPING_CANNOT_BE_READONLY); return descriptorException; }
/** * Add all of the objects of the class and all of its subclasses. * The session is needed because there is no other way to find all subclasses. */ public void addAllObjectsForAbstractClass(Class objectsClass, AbstractSession session, Vector allObjects) { ClassDescriptor descriptor = session.getDescriptor(objectsClass); addAllObjectsForClass(objectsClass, allObjects); for (ClassDescriptor child : descriptor.getInheritancePolicy().getChildDescriptors()) { addAllObjectsForAbstractClass(child.getJavaClass(), session, allObjects); } }
/** * Prepare and validate. * Set the element class. */ @Override public void prepare(DatabaseQuery query, AbstractSession session) throws QueryException { if ((getElementClass() == null) && (query.getDescriptor() != null)) { setElementClass(query.getDescriptor().getJavaClass()); } super.prepare(query, session); }
/** * INTERNAL: * Allow for initialization of properties and validation. */ public void preInitialize(AbstractSession session) throws DescriptorException { try { getAttributeAccessor().initializeAttributes(getDescriptor().getJavaClass()); } catch (DescriptorException exception) { exception.setMapping(this); session.getIntegrityChecker().handleError(exception); } }
/** * INTERNAL: Generates the delete all stored procedure for this mapping */ protected StoredProcedureDefinition generateOneToManyMappingDeleteAllProcedure(OneToManyMapping mapping) { ClassDescriptor targetDescriptor = mapping.getReferenceDescriptor(); DeleteAllQuery deleteAllQuery = new DeleteAllQuery(); deleteAllQuery.setDescriptor(targetDescriptor); deleteAllQuery.setReferenceClass(targetDescriptor.getJavaClass()); deleteAllQuery.setSelectionCriteria(mapping.getSelectionCriteria()); return generateOneToManyMappingProcedures(mapping, deleteAllQuery, mapping.getTargetForeignKeyToSourceKeys(), "D_1M_"); }