-->
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.  [ 5 posts ] 
Author Message
 Post subject: SchemaExport - Bug with sized type (like varchar)
PostPosted: Mon Feb 20, 2006 8:38 pm 
Newbie

Joined: Tue Jan 31, 2006 2:29 pm
Posts: 12
I'm tring execute this comands:

NHibernate.Tool.hbm2ddl.SchemaExport se = new NHibernate.Tool.hbm2ddl.SchemaExport(Db.Configuration);
se.SetOutputFile(@"C:\SQL\schema.sql");
se.Create(true, true);

The file 'schema.sql' is created in the folder 'C:\SQL\' but it has size 0KB ... and the tables wasn't created in database.

The .hbm.xml files are createds and are runing in other database.

Is this function implemented or i'm doing something wrong ???

Thanks,
RWagner


Last edited by RWagnerVM on Thu Feb 23, 2006 10:14 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Works correctly
PostPosted: Tue Feb 21, 2006 12:40 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I tried this and it works correctly for me. Are you sure that the DB.Configuration that you are passing to the SchemaExport is correctly configured, what I mean is that all the mapping files have been added to it by either calling AddAssembly or AddFile or other similar methods. If the configuration has all the assembly added it works ok


Top
 Profile  
 
 Post subject: SchemaExport
PostPosted: Tue Feb 21, 2006 7:35 am 
Newbie

Joined: Tue Jan 31, 2006 2:29 pm
Posts: 12
Yes the object Db.Configuration is correctly initilized with AddAssembly method ... and this Db.Configuration ir working correctly.
Is needed some configuration in web.config file ???

Thanks


Top
 Profile  
 
 Post subject: SchemaExport
PostPosted: Tue Feb 21, 2006 7:44 pm 
Newbie

Joined: Tue Jan 31, 2006 2:29 pm
Posts: 12
The Db.Configuration was not correctly configured ... and now it's working fine in MSSQL ... but when i try create tables in MySQL it don't generate the correct create command ...

It's creating this comand:

create table Marca (
id int NOT NULL AUTO_INCREMENT unique,
Descricao varchar not null,
primary key (id)
)

but it don't put the length of varchar type ...

create table Marca (
id int NOT NULL AUTO_INCREMENT unique,
Descricao varchar(100) not null,
primary key (id)
)

My .hbm.xml mapping file has the attribute length:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Entity.Modelo, Carros" table="Modelo">
<id name="Id" type="Int32" unsaved-value="0">
<column name="Id" sql-type="int" not-null="true" unique="true" index="PK_Modelo"/>
<generator class="native" />
</id>
<property name="Descricao" type="String">
<column name="Descricao" length="100" sql-type="varchar" not-null="true"/>
</property>
<many-to-one name="Marca" class="Entity.Marca, Carros">
<column name="idMarca" sql-type="int" not-null="true" index="IX_Modelo"/>
</many-to-one>
</class>
</hibernate-mapping>


i'm doing something wrong ???

Thanks,
RWagnerVM


Top
 Profile  
 
 Post subject: SchemaExport - Bug with sized type (like varchar)
PostPosted: Thu Feb 23, 2006 10:13 pm 
Newbie

Joined: Tue Jan 31, 2006 2:29 pm
Posts: 12
I modified the method GetSqlType of class NHibernate.Mapping.Column to correct this "bug".

Do i shold register this bug in JIRA ???


public string GetSqlType( Dialect.Dialect dialect, IMapping mapping )
{
if( sqlType == null )
{
SqlType sqlTypeObject = GetAutoSqlType( mapping );
if( Length != DefaultPropertyLength )
{
return dialect.GetTypeName( sqlTypeObject, Length );
}
else
{
return dialect.GetTypeName( sqlTypeObject );
}
}
else
{
if( Length != DefaultPropertyLength )
return sqlType + "(" + Length + ")";
else

return sqlType;
}
}


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

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.