.ExposeConfiguration(BuildSchema) That line tries to create all the tables, if they exist it'll fail. It's expecting an in-memory database as the example used. Create your tables (either manually or by letting the app run once) and remove that line.
On Mon, Jul 20, 2009 at 3:54 AM, Buddy Lindsey, Jr. <[email protected]>wrote: > Sorry for the confusing code. The "WordTypeID" is actually a foriegn key to > another table. Is the mapping I have > > Id(x => x.ID, "GUID").GeneratedBy.Guid(); > > does that generate a new ID? > > Buddy > > > On Sun, Jul 19, 2009 at 7:49 PM, Greg Cook <[email protected]> wrote: > >> yeah, the problem is that you are assigning the Id value of the object >> directly instead of using an ID generator within >> NHibernate. the first time it works because the tabke is empty. >> >> Subsequent 'inserts' are failing because that id is failing on the >> 'primary key constraint' of the table. >> >> If you were using Sql Server it would likely complain that you have not >> "SET IDENTITY_INSERT {table_name} ON" >> on the first insert. >> >> using Fluent is not causing you this problem, this is purely a NHibernate >> mapping issue. >> >> Anyone please correct me if I'm wrong... >> >> Greg >> >> >> On Sun, Jul 19, 2009 at 4:57 PM, percent20 <[email protected]> wrote: >> >>> >>> Am still trying to figure out fluent NHibernate and NHibernate. What >>> I am trying to do right now is figure out how to do an insert and >>> insert more data like a normal insert. >>> >>> As it is right now I am running through the first example and goofing >>> around with it to get a feel for Fluent NHibernate, and am modifying >>> it here and there. Here is my main in program. >>> >>> static void Main(string[] args) >>> { >>> var sessionFactory = CreateSessionFactory(); >>> >>> using (var session = sessionFactory.OpenSession()) >>> { >>> using (var transaction = session.BeginTransaction()) >>> { >>> var help = new Word { TheWord = "throw", >>> WordTypeID = new System.Guid("A2F85066-A296-4453-B9C3- >>> CB795E2CA95D") }; >>> >>> session.Save(help); >>> >>> transaction.Commit(); >>> } >>> >>> Console.ReadKey(); >>> } >>> } >>> >>> Here is mapping for word >>> >>> public class WordMap : ClassMap<Word> >>> { >>> public WordMap() >>> { >>> WithTable("Words"); >>> Id(x => x.ID, "GUID").GeneratedBy.Guid(); >>> Map(x => x.TheWord, "word"); >>> Map(x => x.WordTypeID, "WordTypeGUID"); >>> } >>> } >>> >>> Basically ever time I run the app it just updates the current values >>> instead of inserting new values into it. Been googling for a while >>> but just not understanding. I am not sure if it is a hibernate or >>> fluent hibernate >>> >>> For a couple of other questions. >>> >>> 1) When I use a preexisting table i get a "Object already exists in >>> database" error but when i let fluentnhibernate create a table it >>> works fine'ish except above problem. Am I doing something wrong? >>> 2) Do you create your tables first or let NHiberante do it for you? I >>> ask this because of the question just above. >>> 3) am i just doing something totally wrong? lol. >>> >>> Thanks for any help that can be provided. >>> >>> >>> >> >> >> > > > -- > Buddy Lindsey > http://www.buddylindsey.com > http://www.twitter.com/buddylindsey > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" 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/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
