Hi fellows, I got some strange problem...
This is my Hibernate.cfg.xml
Code:
<?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.MsSqlCeDialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</property>
<property name="connection.connection_string">Data Source=Database1.sdf</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
This is my Entity:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Projeto2.Dominio
{
public class Cliente
{
public virtual Guid Id { get; set; }
public virtual String Nome { get; set; }
public virtual IList<Compra> Compras { get; set; }
public Cliente(string n, IList<Compra> l)
{
Nome = n;
Compras = l;
}
public Cliente()
{
Nome = "";
Compras = null;
}
}
}
This is my *only* mapping:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Projeto2"
namespace="Projeto2.Dominio">
<class name="Cliente" table="cliente">
<id name ="Id">
<generator class = "guid"/>
</id>
<property name="Nome"/>
<list name="Compras" table="comprascliente" cascade="all">
<key column="Compras"/>
<index column="pos"/>
<element column="compra" type="Projeto2.Dominio.Compra"/>
</list>
</class>
</hibernate-mapping>
This is my test:
Code:
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NUnit.Framework;
using Projeto2.Dominio;
namespace Testes
{
[TestFixture]
public class GenerateSchemaFixture
{
[Test]
public void CanGenerateSchema()
{
var cfg = new Configuration();
cfg.Configure();
cfg.AddAssembly(typeof(Cliente).Assembly);
var se = new SchemaExport(cfg);
se.Execute(true,true,false,false);
}
}
}
And finally this is the output:
Quote:
create table Cliente (Id UNIQUEIDENTIFIER not null, Nome NVARCHAR(255) null, primary key (Id))
create table compras (Id UNIQUEIDENTIFIER not null, cliente_id UNIQUEIDENTIFIER not null, primary key (Id))
create table itens (Id UNIQUEIDENTIFIER not null, Nome NVARCHAR(255) null, compra_id UNIQUEIDENTIFIER null, primary key (Id))
alter table compras add constraint FK1D3BD7A79A0495E9 foreign key (cliente_id) references Cliente
alter table itens add constraint FKA33F7B816AC2D813 foreign key (compra_id) references compras
Sometime before Ireally had a mapping for 'compras' but I deleted it to refactor the mapping using a list (I'm still learning)
Is there any kind of cache/buffer ?
I Can see no reason for this output.
Thanks for your help.