Same difference, but I finally figured out what that problem is. Enalbe
STRICT_TRANS_TABLES for your MySQL Server and you should get the exception.

 

From: [email protected]
[mailto:[email protected]] On Behalf Of James Gregory
Sent: Mittwoch, 18. Februar 2009 15:59
To: [email protected]
Subject: [fluent-nhib] Re: Mapping simple datatypes via fluent nhibernate

 

I'm still not able to reproduce this.

 

It's recommended to follow the Fluent
<http://wiki.fluentnhibernate.org/show/FluentConfiguration>  Configuration
approach, rather than using the SessionSource. Have a look at Schema
<http://wiki.fluentnhibernate.org/show/SchemaGeneration>  Generation to see
how I do it.

 

That being said, the SessionSource was using an old way of generating the
schema. I've updated it to use the NHibernate SchemaExport tool. Let me know
if that makes any difference.

 

There's also now an override to BuildSchema that takes a boolean, when true
it'll make NHibernate output the create script to the console. Combine that
with ShowSql in your database configuration and you'll be able to see
everything NHibernate sends to mysql.

On Wed, Feb 18, 2009 at 1:48 PM, Tom Warnat <[email protected]> wrote:

I'm using MySQL 5.0.74 enterprise. A colleague at work tested it with 5.1
and got the same results. Works with MS SQL 2005 though.

 

SQL:

 

create table `Contributor` (ContributorID INTEGER NOT NULL AUTO_INCREMENT,
SequenceNumberWithinRole VARCHAR(255), PersonNameInverted VARCHAR(255),
SequenceNumber VARCHAR(255), ContributorRole VARCHAR(255), primary key
(ContributorID))
create table libri_names (Contributor_id INTEGER not null, Name
VARCHAR(255))
alter table libri_names add index (Contributor_id), add constraint
FK597345084712895B foreign key (Contributor_id) references `Contributor`
(ContributorID)
[18.02.2009 14:39:57] - Executing command QUERY with text ='SHOW VARIABLES'
[18.02.2009 14:39:57] - Executing command QUERY with text ='SHOW COLLATION'
[18.02.2009 14:39:57] - Executing command QUERY with text ='SET NAMES
utf8;SET character_set_results=NULL'
[18.02.2009 14:39:57] - Executing command QUERY with text ='
alter table libri_names  drop foreign key FK597345084712895B
'

 

Exception:

 

MySql.Data.MySqlClient.MySqlException: Table 'libri.libri_names' doesn't
exist

at MySql.Data.MySqlClient.MySqlStream.OpenPacket()
at 

MySql.Data.MySqlClient.NativeDriver.ReadResult(ref UInt64 affectedRows, ref
Int64 lastInsertId)
at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()
at 

MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at 

MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at 

MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at 

FluentNHibernate.SessionSource.executeScripts(IEnumerable`1 scripts,
IDbConnection connection) in 

C:\c# 

Projekte\FluentNHibernate\src\FluentNHibernate\SessionSource.cs: line 83
at 

FluentNHibernate.SessionSource.BuildSchema(ISession session) in C:\c# 

Projekte\FluentNHibernate\src\FluentNHibernate\SessionSource.cs: line 71
at 

Mauve.LibriInterface.DataAccess.Tests.MapTests.SetupContext() 

in MapTests.cs: line 34 

 

Test-Code:

 

[TestFixture]

    public class MapTests

    {

        private SessionSource SessionSource { get; set; }

 

        private ISession Session { get; set; }

 

        [SetUp]

        public void SetupContext()

        {

            this.SessionSource = new SessionSource(new TestModel());

 

            this.Session = SessionSource.CreateSession();

 

            string[] strings =
this.SessionSource.Configuration.GenerateSchemaCreationScript(SessionSource.
Dialect);

 

            foreach (string s in strings)

            {

                Trace.WriteLine(s);

            }

 

            this.SessionSource.BuildSchema(Session);

 

            this.Session.Clear();

        }

 

        [TearDown]

        public void TearDownContext()

        {

            this.Session.Close();

 

            this.Session.Dispose();

        }

 

        [Test]

        public void Contributor_Should_Be_Created_Correctly()

        {

            var contributor = new Contributor();

 

            Session.Save(contributor);

        }

    }

 

The problem seems to be that the schema creation tries to drop a foreign key
on an non existing table. The code works fine if the table is created first
but not if you try to run it on an empty database.

 

Is there an easy way to get the sql created by fluent nhibernate? My
co-worker created some properties for dialect and configuration to get to
the sql. 

 

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of James Gregory
Sent: Mittwoch, 18. Februar 2009 12:46


To: [email protected]
Subject: [fluent-nhib] Re: Mapping simple datatypes via fluent nhibernate

 

I've just installed MySql 5.1 and there isn't an issue, I ran the exact same
code and it produced the same schema as I posted above.

 

What version of MySql are you running on?

How are you creating your schema?

What is the exact exception you're getting?

 

On Wed, Feb 18, 2009 at 10:57 AM, James Gregory <[email protected]>
wrote:

Well, if you're generating your schema then that code you posted should
work. I just ran it and I got:

 

create table [Contributor] (

  Id INT IDENTITY NOT NULL,

   SequenceNumber NVARCHAR(255) null,

   primary key (Id)

)

 

create table Names (

  Contributor_id INT not null,

   MyNames NVARCHAR(255) null

)

 

Which is fine.

 

Admittedly I'm not using MySql but SQLExpress, perhaps there is a problem
with MySql and the schema generation.

 

How are you generating your schema?

 

On Wed, Feb 18, 2009 at 9:58 AM, Tom Warnat <[email protected]> wrote:

I don't understand. The schema is generated by code. So the listmapping
should be creating the table automaticly.

 

Mit freundlichen Grüßen,

 

Tom Warnat

 

Mauve Mailorder Software GmbH & Co KG 

Steeler Wasserturm

Laurentiusweg 83

45276 Essen

 

Fon: 0201 437918 0

Fax: 0201 431918 55

E-Mail: [email protected]

E-Mail: [email protected] (System2)

E-Mail: [email protected] (System3)

E-Mail: [email protected] (Shop)

http://www.mauve.eu/

 

Amtsgericht Essen, HRA 8514
Geschäftsführer Christian Mauve
Ust-Id.DE243763811
St.Nr.111/5770/1703

 

From: [email protected]
[mailto:[email protected]] On Behalf Of James Gregory
Sent: Montag, 16. Februar 2009 10:51


To: [email protected]
Subject: [fluent-nhib] Re: Mapping simple datatypes via fluent nhibernate

 

What's your schema?

On Mon, Feb 16, 2009 at 9:48 AM, Tom Warnat <[email protected]> wrote:

I do.

 

Class:

 

public class Contributor

    {

        #region Properties

 

        public virtual int Id { get; set; }

 

        public virtual string SequenceNumber { get; set; }

 

        public virtual IList<string> Names { get; set; }

 

        #endregion

 

        #region Constructor

 

        public Contributor()

        {

            this.SequenceNumber = String.Empty;

 

            this.Names = new List<string>();

        }

 

        #endregion

    }

 

Mapping:

 

using FluentNHibernate.Mapping;

 

public class ContributorMap : ClassMap<Contributor>

    {

        public ContributorMap()

        {

            Id(x => x.Id);

 

            Map(x => x.SequenceNumber);

            

            HasMany(x => x.Names).AsElement("MyNames"); //WithElement can
not be found…

        }

    }

 

From: [email protected]
[mailto:[email protected]] On Behalf Of James Gregory
Sent: Montag, 16. Februar 2009 10:09


To: [email protected]
Subject: [fluent-nhib] Re: Mapping simple datatypes via fluent nhibernate

 

Well, that code you gave is correct. Did you say you were mapping a
List<string>? Have you tried an IList<string>?

On Mon, Feb 16, 2009 at 8:20 AM, Tom Warnat <[email protected]> wrote:


Hi,

the WithElement-Option ist not valid.

HasMany(x => x. MyListOfStrings).AsElement("foo") would be my only option.

I get a MySql.Data.MySqlClient.MySqlException: Table 'foo' doesn't exist
while running this piece of code.




-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of James Gregory
Sent: Montag, 9. Februar 2009 14:13
To: [email protected]
Subject: [fluent-nhib] Re: Mapping simple datatypes via fluent nhibernate


HasMany(x => x.MyListOfStrings)
 .WithElement("string column name")

This is from memory so it may not be exact.

On 2/9/09, Tom Warnat <[email protected]> wrote:
>
> Hi,
>
> i've tryed to map a list of string via fluent nhibernate lately and i
> can't get it to run.
>
> So googling for 8 hours on friday i'll take my shoot here.
>
> Can anyone tell me to map a simply a List<string>? Furthermore how get
> fluent nhibernate to automatically create the relation for the list
> (which is basically my problem)?
>
> thanks in advance.
>
> >
>




 

 

 

 

 

 

 

 

 

 

 

 




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to