public NativeSQLQuerySpecification( string queryString, INativeSQLQueryReturn[] sqlQueryReturns, ICollection<string> querySpaces) { this.queryString = queryString; this.sqlQueryReturns = sqlQueryReturns; if (querySpaces == null) { this.querySpaces = new IESI.HashedSet<string>(); } else { var tmp = new IESI.HashedSet<string>(); tmp.AddAll(querySpaces); // Can't use ImmutableSet here because it doesn't implement GetHashCode properly. this.querySpaces = tmp; } // pre-determine and cache the hashcode int hCode = queryString.GetHashCode(); unchecked { hCode = 29 * hCode + CollectionHelper.GetHashCode(this.querySpaces); if (this.sqlQueryReturns != null) { hCode = 29 * hCode + CollectionHelper.GetHashCode(this.sqlQueryReturns); } } hashCode = hCode; }
public CriteriaJoinWalker(IOuterJoinLoadable persister, CriteriaQueryTranslator translator, ISessionFactoryImplementor factory, ICriteria criteria, string rootEntityName, IDictionary<string, IFilter> enabledFilters) : base(translator.RootSQLAlias, persister, factory, enabledFilters) { this.translator = translator; querySpaces = translator.GetQuerySpaces(); if (translator.HasProjection) { resultTypes = translator.ProjectedTypes; InitProjection( translator.GetSelect(enabledFilters), translator.GetWhereCondition(enabledFilters), translator.GetOrderBy(), translator.GetGroupBy(), translator.GetHavingCondition(enabledFilters), enabledFilters, LockMode.None); } else { resultTypes = new IType[] {TypeFactory.ManyToOne(persister.EntityName)}; InitAll(translator.GetWhereCondition(enabledFilters), translator.GetOrderBy(), LockMode.None); } userAliasList.Add(criteria.Alias); //root entity comes *last* userAliases = ArrayHelper.ToStringArray(userAliasList); }
protected internal AbstractFieldInterceptor(ISessionImplementor session, IESI.ISet<string> uninitializedFields, IESI.ISet<string> unwrapProxyFieldNames, string entityName, System.Type mappedClass) { this.session = session; this.uninitializedFields = uninitializedFields; this.unwrapProxyFieldNames = unwrapProxyFieldNames ?? new IESI.HashedSet<string>(); this.entityName = entityName; this.mappedClass = mappedClass; }
public SubselectFetch(string alias, ILoadable loadable, QueryParameters queryParameters, IESI.ISet<EntityKey> resultingEntityKeys) { this.resultingEntityKeys = resultingEntityKeys; this.queryParameters = queryParameters; this.loadable = loadable; this.alias = alias; queryString = queryParameters.ProcessedSql.GetSubselectString(); }
public Contract(Plan plan, string customerName, string type) { if (plan != null) { plans.Add(plan); plan.Contracts.Add(this); } this.customerName = customerName; this.type = type; variations = new List<ContractVariation>(); subcontracts = new IESI.HashedSet<Contract>(); parties = new IESI.HashedSet<Party>(); infos = new IESI.HashedSet<Info>(); }
public virtual void SetUp() { _aInitValues = new List<string>(); _aInitValues.Add("zero"); _aInitValues.Add("one"); _aInitValues.Add("two"); _aInitValues.Add("three"); _bInitValues = new List<string>(); _bInitValues.Add("two"); _bInitValues.Add("three"); _bInitValues.Add("four"); _set = CreateInstance(new string[] {one, two, three}); }
protected AbstractEntityPersister(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) { this.factory = factory; this.cache = cache; isLazyPropertiesCacheable = persistentClass.IsLazyPropertiesCacheable; cacheEntryStructure = factory.Settings.IsStructuredCacheEntriesEnabled ? (ICacheEntryStructure)new StructuredCacheEntry(this) : (ICacheEntryStructure)new UnstructuredCacheEntry(); entityMetamodel = new EntityMetamodel(persistentClass, factory); if (persistentClass.HasPocoRepresentation) { //TODO: this is currently specific to pojos, but need to be available for all entity-modes foreach (Subclass subclass in persistentClass.SubclassIterator) { entityNameBySubclass[subclass.MappedClass] = subclass.EntityName; } } batchSize = persistentClass.BatchSize.HasValue ? persistentClass.BatchSize.Value : factory.Settings.DefaultBatchFetchSize; hasSubselectLoadableCollections = persistentClass.HasSubselectLoadableCollections; propertyMapping = new BasicEntityPropertyMapping(this); #region IDENTIFIER identifierColumnSpan = persistentClass.Identifier.ColumnSpan; rootTableKeyColumnNames = new string[identifierColumnSpan]; identifierAliases = new string[identifierColumnSpan]; rowIdName = persistentClass.RootTable.RowId; loaderName = persistentClass.LoaderName; // TODO NH: Not safe cast to Column int i = 0; foreach (Column col in persistentClass.Identifier.ColumnIterator) { rootTableKeyColumnNames[i] = col.GetQuotedName(factory.Dialect); identifierAliases[i] = col.GetAlias(factory.Dialect, persistentClass.RootTable); i++; } #endregion #region VERSION if (persistentClass.IsVersioned) { foreach (Column col in persistentClass.Version.ColumnIterator) { versionColumnName = col.GetQuotedName(factory.Dialect); break; //only happens once } } else { versionColumnName = null; } #endregion #region WHERE STRING sqlWhereString = !string.IsNullOrEmpty(persistentClass.Where) ? "( " + persistentClass.Where + ") " : null; sqlWhereStringTemplate = sqlWhereString == null ? null : Template.RenderWhereStringTemplate(sqlWhereString, factory.Dialect, factory.SQLFunctionRegistry); #endregion #region PROPERTIES // NH: see consistence with the implementation on EntityMetamodel where we are disabling lazy-properties for no lazy entities bool lazyAvailable = IsInstrumented(EntityMode.Poco) && entityMetamodel.IsLazy; int hydrateSpan = entityMetamodel.PropertySpan; propertyColumnSpans = new int[hydrateSpan]; propertySubclassNames = new string[hydrateSpan]; propertyColumnAliases = new string[hydrateSpan][]; propertyColumnNames = new string[hydrateSpan][]; propertyColumnFormulaTemplates = new string[hydrateSpan][]; propertyUniqueness = new bool[hydrateSpan]; propertySelectable = new bool[hydrateSpan]; propertyColumnUpdateable = new bool[hydrateSpan][]; propertyColumnInsertable = new bool[hydrateSpan][]; ISet thisClassProperties = new HashedSet(); lazyProperties = new IESI.HashedSet<string>(); List<string> lazyNames = new List<string>(); List<int> lazyNumbers = new List<int>(); List<IType> lazyTypes = new List<IType>(); List<string[]> lazyColAliases = new List<string[]>(); i = 0; bool foundFormula = false; foreach (Property prop in persistentClass.PropertyClosureIterator) { thisClassProperties.Add(prop); int span = prop.ColumnSpan; propertyColumnSpans[i] = span; propertySubclassNames[i] = prop.PersistentClass.EntityName; string[] colNames = new string[span]; string[] colAliases = new string[span]; string[] templates = new string[span]; int k = 0; foreach (ISelectable thing in prop.ColumnIterator) { colAliases[k] = thing.GetAlias(factory.Dialect, prop.Value.Table); if (thing.IsFormula) { foundFormula = true; templates[k] = thing.GetTemplate(factory.Dialect, factory.SQLFunctionRegistry); } else { colNames[k] = thing.GetTemplate(factory.Dialect, factory.SQLFunctionRegistry); } k++; } propertyColumnNames[i] = colNames; propertyColumnFormulaTemplates[i] = templates; propertyColumnAliases[i] = colAliases; if (lazyAvailable && prop.IsLazy) { lazyProperties.Add(prop.Name); lazyNames.Add(prop.Name); lazyNumbers.Add(i); lazyTypes.Add(prop.Value.Type); lazyColAliases.Add(colAliases); } propertyColumnUpdateable[i] = prop.Value.ColumnUpdateability; propertyColumnInsertable[i] = prop.Value.ColumnInsertability; propertySelectable[i] = prop.IsSelectable; propertyUniqueness[i] = prop.Value.IsAlternateUniqueKey; i++; } hasFormulaProperties = foundFormula; lazyPropertyColumnAliases = lazyColAliases.ToArray(); lazyPropertyNames = lazyNames.ToArray(); lazyPropertyNumbers = lazyNumbers.ToArray(); lazyPropertyTypes = lazyTypes.ToArray(); #endregion #region SUBCLASS PROPERTY CLOSURE List<string> columns = new List<string>(); List<bool> columnsLazy = new List<bool>(); List<string> aliases = new List<string>(); List<string> formulas = new List<string>(); List<string> formulaAliases = new List<string>(); List<string> formulaTemplates = new List<string>(); List<bool> formulasLazy = new List<bool>(); List<IType> types = new List<IType>(); List<string> names = new List<string>(); List<string> classes = new List<string>(); List<string[]> templates2 = new List<string[]>(); List<string[]> propColumns = new List<string[]>(); List<FetchMode> joinedFetchesList = new List<FetchMode>(); List<CascadeStyle> cascades = new List<CascadeStyle>(); List<bool> definedBySubclass = new List<bool>(); List<int[]> propColumnNumbers = new List<int[]>(); List<int[]> propFormulaNumbers = new List<int[]>(); List<bool> columnSelectables = new List<bool>(); List<bool> propNullables = new List<bool>(); foreach (Property prop in persistentClass.SubclassPropertyClosureIterator) { names.Add(prop.Name); classes.Add(prop.PersistentClass.EntityName); bool isDefinedBySubclass = !thisClassProperties.Contains(prop); definedBySubclass.Add(isDefinedBySubclass); propNullables.Add(prop.IsOptional || isDefinedBySubclass); //TODO: is this completely correct? types.Add(prop.Type); string[] cols = new string[prop.ColumnSpan]; string[] forms = new string[prop.ColumnSpan]; int[] colnos = new int[prop.ColumnSpan]; int[] formnos = new int[prop.ColumnSpan]; int l = 0; bool lazy = prop.IsLazy && lazyAvailable; foreach (ISelectable thing in prop.ColumnIterator) { if (thing.IsFormula) { string template = thing.GetTemplate(factory.Dialect, factory.SQLFunctionRegistry); formnos[l] = formulaTemplates.Count; colnos[l] = -1; formulaTemplates.Add(template); forms[l] = template; formulas.Add(thing.GetText(factory.Dialect)); formulaAliases.Add(thing.GetAlias(factory.Dialect)); formulasLazy.Add(lazy); } else { string colName = thing.GetTemplate(factory.Dialect, factory.SQLFunctionRegistry); colnos[l] = columns.Count; //before add :-) formnos[l] = -1; columns.Add(colName); cols[l] = colName; aliases.Add(thing.GetAlias(factory.Dialect, prop.Value.Table)); columnsLazy.Add(lazy); columnSelectables.Add(prop.IsSelectable); } l++; } propColumns.Add(cols); templates2.Add(forms); propColumnNumbers.Add(colnos); propFormulaNumbers.Add(formnos); joinedFetchesList.Add(prop.Value.FetchMode); cascades.Add(prop.CascadeStyle); } subclassColumnClosure = columns.ToArray(); subclassColumnAliasClosure = aliases.ToArray(); subclassColumnLazyClosure = columnsLazy.ToArray(); subclassColumnSelectableClosure = columnSelectables.ToArray(); subclassFormulaClosure = formulas.ToArray(); subclassFormulaTemplateClosure = formulaTemplates.ToArray(); subclassFormulaAliasClosure = formulaAliases.ToArray(); subclassFormulaLazyClosure = formulasLazy.ToArray(); subclassPropertyNameClosure = names.ToArray(); subclassPropertySubclassNameClosure = classes.ToArray(); subclassPropertyTypeClosure = types.ToArray(); subclassPropertyNullabilityClosure = propNullables.ToArray(); subclassPropertyFormulaTemplateClosure = templates2.ToArray(); subclassPropertyColumnNameClosure = propColumns.ToArray(); subclassPropertyColumnNumberClosure = propColumnNumbers.ToArray(); subclassPropertyFormulaNumberClosure = propFormulaNumbers.ToArray(); subclassPropertyCascadeStyleClosure = cascades.ToArray(); subclassPropertyFetchModeClosure = joinedFetchesList.ToArray(); propertyDefinedOnSubclass = definedBySubclass.ToArray(); #endregion // Handle any filters applied to the class level filterHelper = new FilterHelper(persistentClass.FilterMap, factory.Dialect, factory.SQLFunctionRegistry); temporaryIdTableName = persistentClass.TemporaryIdTableName; temporaryIdTableDDL = persistentClass.TemporaryIdTableDDL; }
private static IESI.ISet<EntityKey>[] Transpose(IList<EntityKey[]> keys) { IESI.ISet<EntityKey>[] result = new IESI.ISet<EntityKey>[keys[0].Length]; for (int j = 0; j < result.Length; j++) { result[j] = new IESI.HashedSet<EntityKey>(); for (int i = 0; i < keys.Count; i++) { EntityKey key = keys[i][j]; if (key != null) { result[j].Add(key); } } } return result; }
public ProductCategory() { _products = new IESI.HashedSet<Product>(); }
public AssignmentSpecification(IASTNode eq, IQueryable persister) { if (eq.Type != HqlSqlWalker.EQ) { throw new QueryException("assignment in set-clause not associated with equals"); } _eq = eq; _factory = persister.Factory; // Needed to bump this up to DotNode, because that is the only thing which currently // knows about the property-ref path in the correct format; it is either this, or // recurse over the DotNodes constructing the property path just like DotNode does // internally DotNode lhs; try { lhs = (DotNode)eq.GetFirstChild(); } catch (InvalidCastException e) { throw new QueryException( string.Format("Left side of assigment should be a case sensitive property or a field (depending on mapping); found '{0}'", eq.GetFirstChild()), e); } var rhs = (SqlNode)lhs.NextSibling; ValidateLhs(lhs); string propertyPath = lhs.PropertyPath; var temp = new IESI.HashedSet<string>(); // yuck! var usep = persister as UnionSubclassEntityPersister; if (usep!=null) { temp.AddAll(persister.ConstraintOrderedTableNameClosure); } else { temp.Add(persister.GetSubclassTableName(persister.GetSubclassPropertyTableNumber(propertyPath))); } _tableNames = new IESI.ImmutableSet<string>(temp); if (rhs == null) { _hqlParameters = new IParameterSpecification[0]; } else if (IsParam(rhs)) { _hqlParameters = new[] { ((ParameterNode)rhs).HqlParameterSpecification }; } else { var parameterList = ASTUtil.CollectChildren(rhs, IsParam); _hqlParameters = new IParameterSpecification[parameterList.Count]; int i = 0; foreach (ParameterNode parameterNode in parameterList) { _hqlParameters[i++] = parameterNode.HqlParameterSpecification; } } }
public void PostInitialize(IESI.ISet<System.Type> indexedClasses) { // this method does not requires synchronization Type plainClass = rootClassMapping.MappedClass; IESI.ISet<Type> tempMappedSubclasses = new IESI.HashedSet<System.Type>(); // together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class foreach (Type currentClass in indexedClasses) { if (plainClass.IsAssignableFrom(currentClass)) { tempMappedSubclasses.Add(currentClass); } } mappedSubclasses = tempMappedSubclasses; }
public FilterQueryPlanKey(string query, string collectionRole, bool shallow, IDictionary<string, IFilter> enabledFilters) { this.query = query; this.collectionRole = collectionRole; this.shallow = shallow; if (enabledFilters == null || (enabledFilters.Count == 0)) { filterNames = new IESI.HashedSet<string>(); } else { filterNames = new IESI.HashedSet<string>(enabledFilters.Keys); } int hash = query.GetHashCode(); hash = 29 * hash + collectionRole.GetHashCode(); hash = 29 * hash + (shallow ? 1 : 0); hash = 29 * hash + CollectionHelper.GetHashCode(filterNames); hashCode = hash; }
public Supplier() { _products = new IESI.HashedSet<Product>(); }
public Person() { Accounts = new IESI.HashedSet<Account>(); }
public Plan(string description) { this.description = description; this.contracts = new IESI.HashedSet<Contract>(); this.infos = new IESI.HashedSet<Info>(); }
private void InitTransientState() { loadContexts = null; nullAssociations = new IESI.HashedSet<AssociationKey>(); nonlazyCollections = new List<IPersistentCollection>(InitCollectionSize); }
private object InitializeField(string fieldName, object target) { object result; initializing = true; try { var lazyPropertyInitializer = ((ILazyPropertyInitializer) session.Factory.GetEntityPersister(entityName)); result = lazyPropertyInitializer.InitializeLazyProperty(fieldName, target, session); } finally { initializing = false; } uninitializedFields = null; //let's assume that there is only one lazy fetch group, for now! return result; }
private void AddChild(FromClause fromClause) { if (_childFromClauses == null) { _childFromClauses = new IESI.HashedSet<FromClause>(); } _childFromClauses.Add(fromClause); }
public H(string data) { this.data = data; gs = new IESI.HashedSet<G>(); }
public TreeNode() { DirectChildren = new IESI.HashedSet<TreeNode>(); }
public Employee() { _subordinates = new IESI.HashedSet<Employee>(); _orders = new IESI.HashedSet<Order>(); _territories = new List<Territory>(); }
private G g; // A 1 - 1 G public A() { hs = new IESI.HashedSet<H>(); }