I am developing somekind of CMS web app. After few additions to the DB it experiences huge performance problems. I'm new to the ActiveRecord / NHibernate world. So probably I'm making some configuration mistakes, but I'm not able to solve it.
I have tried using lazy relations and it seems to improve a lot. But now I'm getting the famous 'Failed to lazily initialize a collection - no session' error. However, I have to encapsulate all db related actions in a dll apart so I cannot enable the session-per-request as suggested in http://using.castleproject.org/display/AR/Enable+Session+per+Request I don't even know if the lazy relations solution is the correct approach. Any clue? Thanks in advance!! I'm initializing ActiveRecord through an InPlaceConfigurationSource. The basic scheme, designed with ActiveWriter, looks like this (summarized) |------------(n-m)--------------------- >>CMSTransientCategory<<-----------------(n-m) --------| | | | | |--->>CMSTransientApplication<<---------(n-m)------------- >>CMSTransientPackage<<---| | | | |---------(1-n)----->>CMSTransientFileInstance<<----(n- m)----->>CMSTransientOperatingSystem | | | | CMSTransientFileInformation<<----(1-n)----| |---(1-n)-- >>CMSTransientContentType These are the parameters used for initialization isWeb=True isDebug=False hibernate.connection.driver_class=NHibernate.Driver.SqlClientDriver hibernate.dialect=NHibernate.Dialect.MsSql2005Dialect hibernate.connection.provider=NHibernate.Connection.DriverConnectionProvider hibernate.connection.connection_string=Server=192.168.1.202\sqlexpress;Database=mssf;Uid=******;Pwd=*********; And the generated classes are [ActiveRecord()] public partial class CMSTransientCategory : CMSTransientEntity<CMSTransientCategory> { private IList<CMSTransientPackage> _packages; private IList<CMSTransientApplication> _applications; [HasAndBelongsToMany(typeof(CMSTransientPackage), ColumnRef="PackageId", ColumnKey="CategoryId", Table="Packages2Categories")] public virtual IList<CMSTransientPackage> Packages { get {return this._packages;} set {this._packages = value;} } [HasAndBelongsToMany(typeof(CMSTransientApplication), ColumnRef="ApplicationId", ColumnKey="CategoryId", Table="Applications2Categories")] public virtual IList<CMSTransientApplication> Applications { get {return this._applications;} set{this._applications = value;} } } [ActiveRecord()] public partial class CMSTransientPackage : CMSTransientEntity<CMSTransientPackage> { private IList<CMSTransientCategory> _categories; private IList<CMSTransientApplication> _applications; [HasAndBelongsToMany(typeof(CMSTransientCategory), ColumnRef="CategoryId", ColumnKey="PackageId", Table="Packages2Categories")] public virtual IList<CMSTransientCategory> Categories { get {return this._categories;} set{this._categories = value;} } [HasAndBelongsToMany(typeof(CMSTransientApplication), ColumnRef="ApplicationId", ColumnKey="PackageId", Table="Applications2Packages")] public virtual IList<CMSTransientApplication> Applications { get {return this._applications;} set{this._applications = value;} } } [ActiveRecord()] public partial class CMSTransientApplication : CMSTransientEntity<CMSTransientApplication> { private bool _isExecutable; private bool _isRam; private IList<CMSTransientFileInstance> _fileInstances = new List<CMSTransientFileInstance>(); private IList<CMSTransientCategory> _categories; private IList<CMSTransientPackage> _packages; [Property(ColumnType="Boolean")] public virtual bool IsExecutable { get {return this._isExecutable;} set{this._isExecutable = value;} } [Property(ColumnType="Boolean")] public virtual bool IsRam { get {return this._isRam;} set{this._isRam = value;} } [HasMany(typeof(CMSTransientFileInstance), Lazy=true)] public virtual IList<CMSTransientFileInstance> FileInstances { get {return this._fileInstances;} set{this._fileInstances = value;} } [HasAndBelongsToMany(typeof(CMSTransientCategory), ColumnRef="CategoryId", ColumnKey="ApplicationId", Table="Applications2Categories")] public virtual IList<CMSTransientCategory> Categories { get {return this._categories;} set{this._categories = value;} } [HasAndBelongsToMany(typeof(CMSTransientPackage), ColumnRef="PackageId", ColumnKey="ApplicationId", Table="Applications2Packages")] public virtual IList<CMSTransientPackage> Packages { get {return this._packages;} set{this._packages = value;} } } [ActiveRecord()] public partial class CMSTransientFileInstance : ActiveRecordBase<CMSTransientFileInstance> { private int _id; private string _name; private CMSTransientContentType _contentType; private CMSTransientApplication _application; private CMSTransientFileInformation _fileInformation; private IList<CMSTransientOperativeSystem> _operativeSystems; [PrimaryKey(PrimaryKeyType.Native, ColumnType="Int32")] public virtual int Id { get {return this._id;} set{this._id = value;} } [Property(ColumnType="String")] public virtual string Name { get {return this._name;} set{this._name = value;} } [BelongsTo("ContentTypeId")] public virtual CMSTransientContentType ContentType { get {return this._contentType;} set{this._contentType = value; } } [BelongsTo("ApplicationId", NotNull=true)] public virtual CMSTransientApplication Application { get {return this._application;} set{this._application = value;} } [BelongsTo("FileInformationId")] public virtual CMSTransientFileInformation FileInformation { get {return this._fileInformation;} set{this._fileInformation = value;} } [HasAndBelongsToMany(typeof(CMSTransientOperativeSystem), ColumnRef="OperativeSystemId", ColumnKey="FileId", Lazy=true, Table="Files2OperativeSystems")] public virtual IList<CMSTransientOperativeSystem> OperativeSystems { get {return this._operativeSystems;} set{this._operativeSystems = value; } } } [ActiveRecord()] public partial class CMSTransientContentType : ActiveRecordBase<CMSTransientContentType> { private int _id; private string _name; private string _mIMEType; private IList<CMSTransientFileInstance> _files = new List<CMSTransientFileInstance>(); [PrimaryKey(PrimaryKeyType.Native, ColumnType="Int32")] public virtual int Id { get {return this._id;} set{this._id = value;} } [Property("Description", ColumnType="String", NotNull=true)] public virtual string Name { get {return this._name;} set{this._name = value;} } [Property(ColumnType="String")] public virtual string MIMEType { get {return this._mIMEType;} set{this._mIMEType = value;} } [HasMany(typeof(CMSTransientFileInstance), Lazy=true)] public virtual IList<CMSTransientFileInstance> Files { get {return this._files;} set{this._files = value;} } } [ActiveRecord()] public partial class CMSTransientFileInformation : ActiveRecordBase<CMSTransientFileInformation> { private int _id; private System.Guid _downloadId; private byte[] _fileData; private int _fileSize; private string _fileLocation; private string _fileHash; private IList<CMSTransientFileInstance> _fileInstances = new List<CMSTransientFileInstance>(); [PrimaryKey(PrimaryKeyType.Native, ColumnType="Int32")] public virtual int Id { get {return this._id;} set{this._id = value;} } [Property(ColumnType="Guid")] public virtual System.Guid DownloadId { get {return this._downloadId;} set{this._downloadId = value;} } [Property(ColumnType="BinaryBlob", SqlType="VARBINARY(MAX)")] public virtual byte[] FileData { get {return this._fileData;} set{this._fileData = value;} } [Property(ColumnType="Int32")] public virtual int FileSize { get {return this._fileSize;} set{this._fileSize = value;} } [Property(ColumnType="String")] public virtual string FileLocation { get {return this._fileLocation;} set{this._fileLocation = value;} } [Property(ColumnType="String")] public virtual string FileHash { get {return this._fileHash;} set{this._fileHash = value;} } [HasMany(typeof(CMSTransientFileInstance), Lazy=true)] public virtual IList<CMSTransientFileInstance> FileInstances { get {return this._fileInstances;} set{this._fileInstances = value;} } } [ActiveRecord()] public partial class CMSTransientOperativingSystem : ActiveRecordBase<CMSTransientOperativingSystem> { private int _id; private string _oScode; private IList<CMSTransientFileInstance> _files; [PrimaryKey(PrimaryKeyType.Native, ColumnType="Int32")] public virtual int Id { get {return this._id;} set{this._id = value;} } [Property(ColumnType="String", NotNull=true)] public virtual string OScode { get {return this._oScode;} set{this._oScode = value;} } [HasAndBelongsToMany(typeof(CMSTransientFileInstance), ColumnRef="FileId", ColumnKey="OperativeSystemId", Lazy=true, Table="Files2OperativeSystems")] public virtual IList<CMSTransientFileInstance> Files { get {return this._files;} set{this._files = value;} } } [ActiveRecord(Lazy=true)] public partial class CMSTransientEntity<T> : ActiveRecordBase { private int _id; private string _name; private string _description; private System.Guid _downloadId; private string _customerId; [PrimaryKey(PrimaryKeyType.Native, ColumnType="Int32")] public virtual int Id { get { return this._id;} set {this._id = value;} } [Property(ColumnType="String")] public virtual string Name { get {return this._name;} set {this._name = value;} } [Property(ColumnType="String")] public virtual string Description { get {return this._description;} set {this._description = value;} } [Property(ColumnType="Guid", Unique=true)] public virtual System.Guid DownloadId { get {return this._downloadId;} set { this._downloadId = value;} } [Property(ColumnType="String")] public virtual string CustomerId { get {return this._customerId;} set {this._customerId = value;} } } Regads Corisco! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
