These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Strange output from Schema Export
PostPosted: Wed Oct 14, 2009 11:17 am 
Newbie

Joined: Wed Oct 14, 2009 11:11 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.