Thank you (both) - that was precisely it, when I added table="Users" to my mapping, it worked happily. Is there a similar naming-strategy for NHibernate as there is (I seem to remember reading about, anyhow) for Castle ActiveRecord, that will pluralize table-names automatically? (Or am I misremembering and it's something ActiveWriter does?)
Regards Pete On Sep 3, 11:45 pm, "Ayende Rahien" <[EMAIL PROTECTED]> wrote: > Probably User is a reserved name, try putting it using "`User`" instead. > > On Wed, Sep 3, 2008 at 5:31 PM, petemounce <[EMAIL PROTECTED]> wrote: > > > Hi there > > > I'm new to NHibernate and attempting to learn it. I found a step-by- > > step guide at > >http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/01/your... > > which seems useful and up-to-date - I'm following that, but against my > > own application (which is comparably simple, however, so far!), and > > have encountered a problem. > > > When I attempt to execute a schema-export for my domain class [1] > > (mapping [2]) in an NUnit unit-test [3], against SQL CE 3.5 (based on > > the assembly version in the System.Data.SqlServerCe.dll properties > > dialog), I get an exception as at [4]. I am using NHibernate from > > revision 2.1.0.1001 (based on the assembly-version in properties, > > again), but I get the same error when I build and reference trunk. > > The SQL that NHibernate appears to want to run (I've debugged into > > Execute) is "Drop Table User" (which really sounds as if it should > > work!). > > > I have created the database that I'm working with inside of Visual > > Studio 2008. I haven't used SQL CE before; is there a tool I can use > > like Query Analyzer Lite or SQL Management Studio? Or a command line > > interface I can execute queries/scripts with? > > > I note that if I install SQL CE myself, it uses a slightly more recent > > set of DLLs than the article's source code does; this does not seem to > > make a difference. > > > I guess I could work-around this by using SQLite? However, I'd really > > quite like to get to the bottom of this. > > > Thanks in advance! > > > Best regards > > Pete > > > [1] ( note, PasswordHash is only a string while I'm > > experimenting ;-) ) > > > public class User : IEquatable<User>, ICloneable > > { > > protected User() {} > > > public User(string email, string passwordHash) > > { > > Email = email; > > PasswordHash = passwordHash; > > IsActivated = false; > > // Identity = new GenericIdentity(email, > > Strings.CustomMonoRailAuthentication); > > } > > > public virtual Guid Id { get; set; } > > > public virtual string PasswordHash { get; set; } > > > [ValidateNonEmpty] > > [ValidateEmail] > > public virtual string Email { get; set; } > > > public virtual bool IsActivated { get; set; } > > > //public IIdentity Identity { get; set; } > > > public virtual bool Equals(User user) > > { > > if (user == null) return false; > > if (!base.Equals(user)) return false; > > return Equals(Email, user.Email); > > } > > > //public bool IsInRole(string role) > > //{ > > // return false; > > //} > > > public virtual object Clone() > > { > > var clone = new User(Email, PasswordHash) { > > IsActivated = > > IsActivated, Id = Id };//, Identity = Identity}; > > return clone; > > } > > > public override int GetHashCode() > > { > > return 29*Email.GetHashCode(); > > } > > > public override string ToString() > > { > > return string.Format("{0}, PasswordHash: {1}, Email: > > {2}, > > IsActivated: {3}, Identity: {4}", base.ToString(), > > PasswordHash, Email, > > IsActivated, "");// > > Identity); > > } > > } > > > [2] (it's marked as an embedded resource, and is certainly being found > > in the assembly I'm using to feed the configuration) > > > <?xml version="1.0" encoding="utf-8" ?> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > assembly="Yoti.Model" > > namespace="Yoti.Model"> > > > <class name="User"> > > <id name="Id"> > > <generator class="guid" /> > > </id> > > <property name="Email" /> > > <property name="PasswordHash" /> > > <property name="IsActivated" /> > > </class> > > > </hibernate-mapping> > > > [3] (it's an NUnit test) > > > [Test] > > public void CanGenerateSchema() > > { > > var cfg = new Configuration(); > > cfg.Configure(); > > cfg.AddAssembly(typeof (NHibernateHelper).Assembly); > > > Assert.Greater(cfg.ClassMappings.Count, 0); > > > new SchemaExport(cfg).Execute(false, true, false, > > false); > > } > > > [4] > > > NHibernateSetupTests.CanGenerateSchema : > > FailedSystem.Data.SqlServerCe.SqlCeException: There was an error > > parsing the query. [ Token line number = 1,Token line offset = > > 14,Token in error = User ] > > at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan() > > at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior > > behavior, String method, ResultSetOptions options) > > at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery() > > at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, > > Boolean export, Boolean format, Boolean throwOnError, TextWriter > > exportOutput, IDbCommand statement, String sql) > > at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, > > Boolean export, Boolean justDrop, Boolean format, IDbConnection > > connection, TextWriter exportOutput) > > at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, > > Boolean export, Boolean justDrop, Boolean format) > > NHibernate.HibernateException: There was an error parsing the query. > > [ Token line number = 1,Token line offset = 14,Token in error = User ] > > at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, > > Boolean export, Boolean justDrop, Boolean format) > > at Yoti.Repositories.Tests.NHibernateSetupTests.CanGenerateSchema() in > > NHibernateSetupTests.cs: line 21 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" 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/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
