Search Results

Search found 1981 results on 80 pages for 'fluent nhibernate'.

Page 5/80 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • nhibernate says 'mapping exception was unhandled' no persister for: MyNH.Domain.User

    - by mrblah
    Hi, I am using nHibernate and fluent. I created a User.cs: public class User { public virtual int Id { get; set; } public virtual string Username { get; set; } public virtual string Password { get; set; } public virtual string Email { get; set; } public virtual DateTime DateCreated { get; set; } public virtual DateTime DateModified { get; set; } } Then in my mappinds folder: public class UserMapping : ClassMap<User> { public UserMapping() { WithTable("ay_users"); Not.LazyLoad(); Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.Username).Not.Nullable().WithLengthOf(256); Map(x => x.Password).Not.Nullable().WithLengthOf(256); Map(x => x.Email).Not.Nullable().WithLengthOf(100); Map(x => x.DateCreated).Not.Nullable(); Map(x => x.DateModified).Not.Nullable(); } } Using the repository pattern for the nhibernate blog: public class UserRepository : Repository<User> { } public class Repository<T> : IRepository<T> { public ISession Session { get { return SessionProvider.GetSession(); } } public T GetById(int id) { return Session.Get<T>(id); } public ICollection<T> FindAll() { return Session.CreateCriteria(typeof(T)).List<T>(); } public void Add(T product) { Session.Save(product); } public void Remove(T product) { Session.Delete(product); } } public interface IRepository<T> { T GetById(int id); ICollection<T> FindAll(); void Add(T entity); void Remove(T entity); } public class SessionProvider { private static Configuration configuration; private static ISessionFactory sessionFactory; public static Configuration Configuration { get { if (configuration == null) { configuration = new Configuration(); configuration.Configure(); configuration.AddAssembly(typeof(User).Assembly); } return configuration; } } public static ISessionFactory SessionFactory { get { if (sessionFactory == null) sessionFactory = Configuration.BuildSessionFactory(); return sessionFactory; } } private SessionProvider() { } public static ISession GetSession() { return SessionFactory.OpenSession(); } } My config: <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <property name="connection.connection_string">Server=.\SqlExpress;Initial Catalog=TestNH;User Id=dev;Password=123</property> <property name="show_sql">true</property> </session-factory> </hibernate-configuration> I created a console application to test the output: static void Main(string[] args) { Console.WriteLine("starting..."); UserRepository users = new UserRepository(); User user = users.GetById(1); Console.WriteLine("user is null: " + (null == user)); if(null != user) Console.WriteLine("User: " + user.Username); Console.WriteLine("ending..."); Console.ReadLine(); } Error: nhibernate says 'mapping exception was unhandled' no persister for: MyNH.Domain.User What could be the issue, I did do the mapping?

    Read the article

  • NHibernate and mysql timestamp

    - by HeavyWave
    I am trying to do versioning with NHibernate and everything works fine, however right after the insert NHibernate tries to pull the generated timestamp by executing the following query: SELECT profileloc_.Updated as Updated14_ FROM profile_locale profileloc_ WHERE profileloc_.id=?p0 and profileloc_.culture=?p1;?p0 = 16, ?p1 = 1033 Which is totally wrong, as it will pull out all versions starting with the first one. How do I make it add ORDER BY Updated DESC to this query? I am using Fluent NHibernate for mappings.

    Read the article

  • Handle cases where Nhibernate subclass does not exist

    - by kaykayman
    I have a scenario where I am using nhibernate to map records from one table to several different derived classes based on a discriminator. public class BaseClass { } public class DerivedClass0 : BaseClass { } public class DerivedClass1 : BaseClass { } public class DerivedClass2 : BaseClass { } I then use nhibernate's DiscriminateSubClassesOnColumn() method and alter the configuration to include <subclass name="DerivedClass0" extends="BaseClass" discriminator-value="discriminator0" /> <subclass name="DerivedClass1" extends="BaseClass" discriminator-value="discriminator1" /> <subclass name="DerivedClass2" extends="BaseClass" discriminator-value="discriminator2" /> so that when mapped, these classes are cast to their derived classes and not BaseClass. However, there are some records in my database which have a discriminator which does not have a corresponding subclass. In these cases, nHibernate throws an error: "Object with id: 'xxx' was not of the specified subclass..." Is there some way I can handle this, so that any records which do not have a corresponding subclass are cast to BaseClass rather than an error being thrown? I have simplified the above as much as possible, however it is worth noting that the XML is edited dynamically which is why I am referencing fluent nhibernate [DiscriminateSubClassesOnColumn()] and XML at the same time. The following things (which would help) are not an option: I cannot correct the data to remove records which are invalid I cannot create subclasses for those records which do not have one I need to handle cases where nHibernate tries to map on a discriminator and finds that one does not exist.

    Read the article

  • How to disable automatic loading in NHibernate?

    - by Drevak
    This question might be a duplicate of this one: http://stackoverflow.com/questions/217761/nhibernate-disable-automatic-lazy-loading-of-child-records-for-one-to-many-rela I'd like to know if there is any way to tell nhibernate to do not load a child collections (best if it's with fluent Nhibernate) unless i do it manually with a query (keeping all the mappings!). The problem is that even turning off lazy loading the collections get eager-loaded automatically. I'd like that no collections are loaded unless I specify a fetchmode in my query.

    Read the article

  • nHibernate: Query tree nodes where self or ancestor matches condition

    - by Famous Nerd
    I have see a lot of competing theories about hierarchical queries in fluent-nHibernate or even basic nHibernate and how they're a difficult beast. Does anyone have any knowledge of good resources on the subject. I find myself needing to do queries similar to: (using a file system analog) select folderObjects from folders where folder.Permissions includes :myPermissionLevel or [any of my ancestors] includes :myPermissionLevel This is a one to many tree, no node has multiple parents. I'm not sure how to describe this in nHibernate specific terms or, even sql-terms. I've seen the phrase "nested sets" mentioned, is this applicable? I'm not sure. Can anyone offer any advice on approaches to writing this sort of nHibernate query?

    Read the article

  • Exception when retrieving record using Nhibernate

    - by Muhammad Akhtar
    I am new to NHibernate and have just started right now. I have very simple table contain Id(Int primary key and auto incremented), Name(varchar(100)), Description(varchar(100)) Here is my XML <class name="DevelopmentStep" table="DevelopmentSteps" lazy="true"> <id name="Id" type="Int32" column="Id"> </id> <property name="Name" column="Name" type="String" length="100" not-null="false"/> <property name="Description" column="Description" type="String" length="100" not-null="false"/> here is how I want to get all the record public List<DevelopmentStep> getDevelopmentSteps() { List<DevelopmentStep> developmentStep; developmentStep = Repository.FindAll<DevelopmentStep>(new OrderBy("Name", Order.Asc)); return developmentStep; } But I am getting exception The element 'id' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping- 2.2:column urn:nhibernate-mapping-2.2:generator'. Please Advise me --- Thanks

    Read the article

  • Hello NHibernate! Quickstart with NHibernate (Part 1)

    - by BobPalmer
    When I first learned NHibernate, I could best describe the experience as less of a learning curve and more like a learning cliff.  A large part of that was the availability of tutorials.  In this first of a series of articles, I will be taking a crack at providing people new to NHibernate the information they need to quickly ramp up with NHibernate. For the first article, I've decided to address the gap of just giving folks enough code to get started.  No UI, no fluff - just enough to connect to a database and do some basic CRUD operations.  In future articles, I will discuss a repository pattern for NHibernate, parent-child relationships, and other more advanced topics. You can find the entire article via this Google Docs link: http://docs.google.com/Doc?docid=0AUP-rKyyUMKhZGczejdxeHZfOGMydHNqdGc0&hl=en Enjoy! -Bob

    Read the article

  • nhibernate configure and buildsessionfactory time

    - by davidsleeps
    Hi, I'm using Nhibernate as the OR/M tool for an asp.net application and the startup performance is really frustrating. Part of the problem is definitely me in my lack of understanding but I've tried a fair bit (understanding is definitely improving) and am still getting nowhere. Currently ANTS profiler has that the Configure() takes 13-18 seconds and the BuildSessionFActory() as taking about 5 seconds. From what i've read, these times might actually be pretty good, but they were generally talking about hundreds upon hundreds of mapped entities...this project only has 10. I've combined all the mapping files into a single hbm mapping file and this did improve things but only down to the times mentioned above... I guess, are there any "Traps for young players" that are regularly missed...obvious "I did this/have you enabled that/exclude file x/mark file y as z" etc... I'll try the serialize the configuration thing to avoid the Configure() stage, but I feel that part shouldn't be that long for that amount of entities and so would essentially be hiding a current problem... I will post source code or configuration if necessary, but I'm not sure what to put in really... thanks heaps! edit (more info) I'll also add that once this is completed, each page is extremely quick... configuration code- hibernate.cfg.xml <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> </configSections> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <property name="connection.connection_string_name">MyAppDEV</property> <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property> <property name="cache.use_second_level_cache">true</property> <property name="show_sql">false</property> <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property> <property name="current_session_context_class">managed_web</property> <mapping assembly="MyApp.Domain"/> </session-factory> </hibernate-configuration> </configuration> My SessionManager class which is bound and unbound in a HttpModule for each request Imports NHibernate Imports NHibernate.Cfg Public Class SessionManager Private ReadOnly _sessionFactory As ISessionFactory Public Shared ReadOnly Property SessionFactory() As ISessionFactory Get Return Instance._sessionFactory End Get End Property Private Function GetSessionFactory() As ISessionFactory Return _sessionFactory End Function Public Shared ReadOnly Property Instance() As SessionManager Get Return NestedSessionManager.theSessionManager End Get End Property Public Shared Function OpenSession() As ISession Return Instance.GetSessionFactory().OpenSession() End Function Public Shared ReadOnly Property CurrentSession() As ISession Get Return Instance.GetSessionFactory().GetCurrentSession() End Get End Property Private Sub New() Dim configuration As Configuration = New Configuration().Configure() _sessionFactory = configuration.BuildSessionFactory() End Sub Private Class NestedSessionManager Friend Shared ReadOnly theSessionManager As New SessionManager() End Class End Class edit 2 (log4net results) will post bits that have a portion of time between them and will cut out the rest... 2010-03-30 23:29:40,898 [4] INFO NHibernate.Cfg.Environment [(null)] - Using reflection optimizer 2010-03-30 23:29:42,481 [4] DEBUG NHibernate.Cfg.Configuration [(null)] - dialect=NHibernate.Dialect.MsSql2005Dialect ... 2010-03-30 23:29:42,501 [4] INFO NHibernate.Cfg.Configuration [(null)] - Mapping resource: MyApp.Domain.Mappings.hbm.xml 2010-03-30 23:29:43,342 [4] INFO NHibernate.Dialect.Dialect [(null)] - Using dialect: NHibernate.Dialect.MsSql2005Dialect 2010-03-30 23:29:50,462 [4] INFO NHibernate.Cfg.XmlHbmBinding.Binder [(null)] - Mapping class: ... 2010-03-30 23:29:51,353 [4] DEBUG NHibernate.Connection.DriverConnectionProvider [(null)] - Obtaining IDbConnection from Driver 2010-03-30 23:29:53,136 [4] DEBUG NHibernate.Connection.ConnectionProvider [(null)] - Closing connection

    Read the article

  • How to change Fluent NHibernate reference column name on a HasMany relationship using IHasManyConven

    - by snicker
    Currently I'm using Fluent NHibernate to generate my database schema, but I want the entities in a HasMany relationship to point to a different column for the reference. IE, this is what NHibernate will generate in the creation DDL: alter table `Pony` add index (Stable_ID), add constraint Ponies_Stable foreign key (Stable_Id) references `Stable` (Id); This is what I want to have: alter table `Pony` add index (Stable_ID), add constraint Ponies_Stable foreign key (Stable_Id) references `Stable` (EntityId); Where Stable.ID would be the primary key and Stable.EntityId is just another column that I set. I have a class already that looks like this: public class ForeignKeyReferenceConvention : IHasManyConvention { public void Apply(IOneToManyCollectionInstance instance) { instance.Cascade.All(); //What goes here so that I can change the reference column? } } What do I have to do to get the reference column to change?

    Read the article

  • Fluent NHibernate - exception occurred during configuration of persistence layer

    - by inutan
    Hello there, I am using Fluent NHibernate with an external 'hibernate.cfg.xml' file. Following is the configuration code where I am getting error: var configuration = new Configuration(); configuration.Configure(); _sessionFactory = Fluently.Configure(configuration) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Template>()) .BuildSessionFactory(); return _sessionFactory; But When NHibernate is trying to configure, I am getting floowing error: An exception occurred during configuration of persistence layer. Please help.

    Read the article

  • using (Fluent) NHibernate with StructureMap (or any IoCC)

    - by Andrew Bullock
    Hi, On my quest to learn NHibernate I have reached the next hurdle; how should I go about integrating it with StructureMap? Although code examples are very welcome, I'm more interested in the general procedure. What I was planning on doing was... Use Fluent NHibernate to create my class mappings for use in NHibs Configuration Implement ISession and ISessionFactory Bootstrap an instance of my ISessionFactory into StructureMap as a singleton Register ISession with StructureMap, with per-HttpRequest caching However, don't I need to call various tidy-up methods on my session instance at the end of the HttpRequest (because thats the end of its life)? If i do the tidy-up in Dispose(), will structuremap take care of this for me? If not, what am I supposed to do? Thanks Andrew

    Read the article

  • Using a Generic Repository pattern with fluent nHibernate

    - by alex
    I'm currently developing a medium sized application, which will access 2 or more SQL databases, on different sites etc... I am considering using something similar to this: http://mikehadlow.blogspot.com/2008/03/using-irepository-pattern-with-linq-to.html However, I want to use fluent nHibernate, in place of Linq-to-SQL (and of course nHibernate.Linq) Is this viable? How would I go about configuring this? Where would my mapping definitions go etc...? This application will eventually have many facets - from a WebUI, WCF Library and Windows applications / services. Also, for example on a "product" table, would I create a "ProductManager" class, that has methods like: GetProduct, GetAllProducts etc... Any pointers are greatly received.

    Read the article

  • Extending fluent nhibernate mappings in another assembly

    - by Jarek
    Hi, I'm using NHibernate with my ASP.Net MVC application. I'm writing some extensions (plugins) for my application. And I'm loading those plugin dynamically (from different assemblies). In my base application I have many entities and mappings defined (User, Group, etc...) I need to create new entities in my extensions, so i.e. I'm creating News module, so I need to create News mapping. In database News table has a foreign key to User table. Is there any way I can modify my User mapping, so it will have: HasMany(x => x.Courses) .KeyColumn("GroupId") .Inverse(); Or the only way to do it is to change code in my User class and recompile project ? I'm not NHibernate advanced user, so any help will be appreciated. TIA.

    Read the article

  • Fluent Nhibernate - how do i specify table schemas when auto generating tables in SQL CE 4

    - by daffers
    I am using SQL CE as a database for running local and CI integration tests (normally our site runs on normal SQL server). We are using Fluent Nhibernate for our mapping and having it create our schema from our Mapclasses. There are only two classes with a one to many relationship between them. In our real database we use a non dbo schema. The code would not work with this real database at first until i added schema names to the Table() methods. However doing this broke the unit tests with the error... System.Data.SqlServerCe.SqlCeException : There was an error parsing the query. [ Token line number = 1,Token line offset = 26,Token in error = User ] These are the classes and associatad MapClasses (simplified of course) public class AffiliateApplicationRecord { public virtual int Id { get; private set; } public virtual string CompanyName { get; set; } public virtual UserRecord KeyContact { get; private set; } public AffiliateApplicationRecord() { DateReceived = DateTime.Now; } public virtual void AddKeyContact(UserRecord keyContactUser) { keyContactUser.Affilates.Add(this); KeyContact = keyContactUser; } } public class AffiliateApplicationRecordMap : ClassMap<AffiliateApplicationRecord> { public AffiliateApplicationRecordMap() { Schema("myschema"); Table("Partner"); Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.CompanyName, "Name"); References(x => x.KeyContact) .Cascade.All() .LazyLoad(Laziness.False) .Column("UserID"); } } public class UserRecord { public UserRecord() { Affilates = new List<AffiliateApplicationRecord>(); } public virtual int Id { get; private set; } public virtual string Forename { get; set; } public virtual IList<AffiliateApplicationRecord> Affilates { get; set; } } public class UserRecordMap : ClassMap<UserRecord> { public UserRecordMap() { Schema("myschema"); Table("[User]");//Square brackets required as user is a reserved word Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.Forename); HasMany(x => x.Affilates); } } And here is the fluent configuraton i am using .... public static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database( MsSqlCeConfiguration.Standard .Dialect<MsSqlCe40Dialect>() .ConnectionString(ConnectionString) .DefaultSchema("myschema")) .Mappings(m => m.FluentMappings.AddFromAssembly(typeof(AffiliateApplicationRecord).Assembly)) .ExposeConfiguration(config => new SchemaExport(config).Create(false, true)) .ExposeConfiguration(x => x.SetProperty("connection.release_mode", "on_close")) //This is included to deal with a SQLCE issue http://stackoverflow.com/questions/2361730/assertionfailure-null-identifier-fluentnh-sqlserverce .BuildSessionFactory(); } The documentation on this aspect of fluent is pretty weak so any help would be appreciated

    Read the article

  • Inherited fluent nhibenate mapping issue

    - by Aim Kai
    I have an interesting issue today!! Basically I have two classes. public class A : B { public virtual new ISet<DifferentItem> Items {get;set;} } public class B { public virtual int Id {get;set;} public virtual ISet<Item> Items {get;set;} } The subclass A hides the base class B property, Items and replaces it with a new property with the same name and a different type. The mappings for these classes are public class AMapping : SubclassMap<A> { public AMapping() { HasMany(x=>x.Items) .LazyLoad() .AsSet(); } } public class BMapping : ClassMap<B> { public BMapping() { Id(x=>x.Id); HasMany(x=>x.Items) .LazyLoad() .AsSet(); } } However when I run my unit test to check the mapping I get the following exception: Tests the A mapping: NHibernate.PropertyAccessException : Invalid Cast (check your mapping for property type mismatches); setter of A ---- System.InvalidCastException : Unable to cast object of type 'NHibernate.Collection.Generic.PersistentGenericSet1[Item]' to type 'Iesi.Collections.Generic.ISet1[DifferentItem]'. Anyone have any ideas? Clearly it is something to do with the type of the collection on the sub-class. But I skimmed through the available options on the mapping class and nothing stood out as being the solution here.

    Read the article

  • Fluent NHibernate Map to private/protected Field that has no exposing Property

    - by Jon Erickson
    I have the following Person and Gender classes (I don't really, but the example is simplified to get my point across), using NHibernate (Fluent NHibernate) I want to map the Database Column "GenderId" [INT] value to the protected int _genderId field in my Person class. How do I do this? FYI, the mappings and the domain objects are in separate assemblies. public class Person : Entity { protected int _genderId; public virtual int Id { get; private set; } public virtual string Name { get; private set; } public virtual Gender Gender { get { return Gender.FromId(_genderId); } } } public class Gender : EnumerationBase<Gender> { public static Gender Male = new Gender(1, "Male"); public static Gender Female = new Gender(2, "Female"); private static readonly Gender[] _genders = new[] { Male, Female }; private Gender(int id, string name) { Id = id; Name = name; } public int Id { get; private set; } public string Name { get; private set; } public static Gender FromId(int id) { return _genders.Where(x => x.Id == id).SingleOrDefault(); } }

    Read the article

  • nhibernate fluent repository pattern insert problem

    - by voam
    I am trying to use Fluent NHibernate and the repository pattern. I would like my business layer to not be knowledgeable of the data persistence layer. Ideally I would pass in an initialized domain object to the insert method of the repository and all would be well. Where I run into problems is if the object being passed in has a child object. For example say I want to insert an a new order for a customer, and the customer is a property of the order object. I would like to do something like this: Customer c = new Customer; c.CustomerId = 1; Order o = new Order; o.Customer = c; repository.InsertOrder(o); The problem is that using NHiberate the CustomerId field is only privately settable so I can not set it directly like this. so what I have ended up doing is have my repository have an interface of Order InsertOrder(int customerId) where all the foreign keys get passed in as parameters. Somehow this just doesn't seem right. The other approach was to use the NHibernate session variable to load a customer object in my business model and then have the order passed in to the repository but this defeats my persistence ignorance ideal. Should I throw this persistence ignorance out the window or am I missing something here? Thanks

    Read the article

  • Fluent / NHibernate Collections of the same class

    - by Charlie Brown
    I am new to NHibernate and I am having trouble mapping the following relationships within this class. public class Category : IAuditable { public virtual int Id { get; set; } public virtual string Name{ get; set; } public virtual Category ParentCategory { get; set; } public virtual IList<Category> SubCategories { get; set; } public Category() { this.Name = string.Empty; this.SubCategories = new List<Category>(); } } Class Maps (although, these are practically guesses) public class CategoryMap : ClassMap<Category> { public CategoryMap() { Id(x => x.Id); Map(x => x.Name); References(x => x.ParentCategory) .Nullable() .Not.LazyLoad(); HasMany(x => x.SubCategories) .Cascade.All(); } } Each Category may have a parent category, some Categories have many subCategories, etc, etc I can get the Category to Save correctly (correct subcategories and parent category fk exist in the database) but when loading, it returns itself as the parent category. I am using Fluent for the class mapping, but if someone could point me in the right direction for just plain NHibernate that would work as well.

    Read the article

  • Mapping a collection of enums with NHibernate

    - by beaufabry
    Mapping a collection of enums with NHibernate Specifically, using Attributes for the mappings. Currently I have this working mapping the collection as type Int32 and NH seems to take care of it, but it's not exactly ideal. The error I receive is "Unable to determine type" when trying to map the collection as of the type of the enum I am trying to map. I found a post that said to define a class as public class CEnumType : EnumStringType { public CEnumType() : base(MyEnum) { } } and then map the enum as CEnumType, but this gives "CEnumType is not mapped" or something similar. So has anyone got experience doing this? So anyway, just a simple reference code snippet to give an example with [NHibernate.Mapping.Attributes.Class(Table = "OurClass")] public class CClass : CBaseObject { public enum EAction { do_action, do_other_action }; private IList<EAction> m_class_actions = new List<EAction>(); [NHibernate.Mapping.Attributes.Bag(0, Table = "ClassActions", Cascade="all", Fetch = CollectionFetchMode.Select, Lazy = false)] [NHibernate.Mapping.Attributes.Key(1, Column = "Class_ID")] [NHibernate.Mapping.Attributes.Element(2, Column = "EAction", Type = "Int32")] public virtual IList<EAction> Actions { get { return m_class_actions; } set { m_class_actions = value;} } } So, anyone got the correct attributes for me to map this collection of enums as actual enums? It would be really nice if they were stored in the db as strings instead of ints too but it's not completely necessary.

    Read the article

  • NHibernate with nothing but stored procedures

    - by ChrisB2010
    I'd like to have NHibernate call a stored procedure when ISession.Get is called to fetch an entity by its key instead of using dynamic SQL. We have been using NHibernate and allowing it to generate our SQL for queries and inserts/updates/deletes, but now may have to deploy our application to an environment that requires us to use stored procedures for all database access. We can use sql-insert, sql-update, and sql-delete in our .hbm.xml mapping files for inserts/updates/deletes. Our hql and criteria queries will have to be replaced with stored procedure calls. However, I have not figured out how to force NHibernate to use a custom stored procedure to fetch an entity by its key. I still want to be able to call ISession.Get, as in: using (ISession session = MySessionFactory.OpenSession()) { return session.Get<Customer>(customerId); } and also lazy load objects, but I want NHibernate to call my "GetCustomerById" stored procedure instead of generating the dynamic SQL. Can this be done? Perhaps NHibernate is no longer a fit given this new environment we must support.

    Read the article

  • NHibernate with or without Repository

    - by Groo
    There are several similar questions on this matter, by I still haven't found enough reasons to decide which way to go. The real question is, is it reasonable to abstract the NHibernate using a Repository pattern, or not? It seems that the only reason behind abstracting it is to leave yourself an option to replace NHibernate with a different ORM if needed. But creating repositories and abstracting queries seems like adding yet another layer, and doing much of the plumbing by hand. One option is to use expose IQueryable<T> to the business layer and use LINQ, but from my experience LINQ support is still not fully implemented in NHibernate (queries simply don't always work as expected, and I hate spending time on debugging a framework). Although referencing NHibernate in my business layer hurts my eyes, it is supposed to be an abstraction of data access by itself, right? What are you opinions on this?

    Read the article

  • How To Make NHibernate Automatically change an "Updated" column

    - by IanT8
    I am applying NHibernate to an existing project, where tables and columns are already defined and fixed. The database is MS-SQL-2008. NHibernate 2.1.2 Many tables have a column of type timestamp named "ReplicationID", and also a column of type datetime named "UpdatedDT". I understand I might be able to use the element of the mapping file to describe the "ReplicationID" column which will allow NHibernate to manage that column. Is it possible to make NHibernate automatically update the UpdatedDT column when the row is updated? I suppose I could try mapping the UpdatedDT property to be of type timestamp, but that have other side effects.

    Read the article

  • NHibernate - auto generate timestamp on create and update ?

    - by driis
    I am trying to map an entity in NHibernate, that should have an Updated column. This should be the DateTime when the entity was last written to the database (either created or updated). I'd like NHibernate to control the update of the column, so I don't need to remember to set a property to the current time before updating. Is there a built-in feature in NHibernate, that can handle this for me ?

    Read the article

  • Fluent NHibernate caching with automapping

    - by md1337
    I'm trying to understand how to configure Fluent NHibernate to enable 2nd-level caching for queries, entities, etc... There is very little information online on how to do that. I see it can be achieved by manually mapping the entities but I don't want that. I want to be able to cache all entities and not address the classes individually. How can I do that? Thanks.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >