schemaexport

NHibernate SchemaExport with generated properties

I'm wondering if there is a way to get SchemaExport to generate and identity column for a generated property. <id name="Id" column="Id" type="Guid"> <generator class="guid.comb" /> </id> <property name="OrderNumber" column="OrderNumber" type="Int32" generated="insert"/> With the mapping above, ShcemaExport does not make the OrderNu...

SchemaExport, NHibernate and deleting foreign keys

I am building my mapping and then using schema export to update my DB. However, if I delete an association in my mapping, since it's no longer in the mapping, when I run SchemaExport, it will not delete the foreign key for the deleted association. This means that it then fails to drop the table associated with that foreign key. Which fur...

Hibernate: How to map a *.hbm.xml file in a different folder?

I have some *.hbm.xml files that are placed in the same folder at the hibernate.cfg.xml file. Now, I want to map some other *.hbm.xml files that are in a subfolder of this folder. How could I do it? Thanks! here's part of my hibernate.cfg.xml: <hibernate-configuration> <session-factory name="MySessionFactory"> <...

Can NHibernate check if the db schema has been generated?

So, newbie NHibernate user; trying to wrap my brain around it. I'm contemplating how to handle deployment, and later injection of add-ons to a web app (which may require their own persistence classes). I was thinking that using SchemaExport for the deployment would work pretty well, but I was wondering if there's a way too get NHiberna...

NHibernate SchemaExport and Configure() catch-22

I want to use DDD in a new project and model my classes first, then generate the database schema based on the class library. My plan is to do this with the NHibernate hbm2ddl tool SchemaExport. The problem is that I can't get the SchemaExport to work because of a weird catch-22 problem it puts me in. The SchemaExport requires a Configur...

NHibernate - SchemaExport Tool Question?

Is it posible to control what objects get generated when using the SchemaExport tool. For example if I have NH mapping files for an EntityA, EntityB, and EntityC how can I exclude C from being created? Roberto.- ...

Using Schema Export Efficiently

Hi all! We are using NHibernate as our ORM framework. We have a need to persist classes we load at run time. We do that according to metadata they come with, that holds names and types of the data they have. In order to build the tables for them at run time, we use the SchemaExport class from the NHibernate ToolSet API. We wanted to as...

SchemaExport with FluentNhibernate

Is there anything wrong with this code. I am not getting anything generated and no exceptions are thrown. public static void ExportSchema() { Configuration cfg = LoadDefaultConfiguration(); Fluently.Configure(cfg) .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.Load("dnnSphere.M...

NHibernate does not create Tables

var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof(<ClassName>).Assembly); new SchemaExport(cfg).Execute(false, true, false, false); The above piece of code is supposed to create a database Table with name But it is not creating... Can someone help me out on this... It is very urgent... ...

Fluent NHibernate: setting string to be sql type of "varchar" instead of "nvarchar"

I have the following mapping: public class LogEntryMap { public LogEntryMap() { Map.Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.Context).CustomSqlType("varchar").Length(512); } } However, using SchemaExport to generate the database in SQL Server 2008, the script generated ignores the length so in effec...

Fluent NHibernate ExportSchema without connection string

I want to generate a database script without having an actual database connection string declared. To do this for now i use NHibernate ExportSchema bases on a NHibernate configuration generated with Fluent NHibernate this way (during my ISessionFactory creation method): FluentConfiguration configuration = Fluently.Configure(); ...

Prevent Nhibernate schemaexport from generating foreign key constraints on has many relationship

I have a mapping like this: HasMany(x => x.Orders).KeyColumn("CustomerID"); Which is causing a constraint like this to be generated by schemaexport: alter table [CustomerOrder] add constraint FK45B3FB85AF01218D foreign key (CustomerID) references [Customer] I have tried adding .NotFound.Ignore() like on a References(...

Foreign Keys with SchemaExport in Fluent NHibernate using SQLite

I am attempting to create a simple database application which keeps track of loans of various types of equipment using Fluent NHibernate and SQLite. However, when I try to generate the database structure with SchemaExport for use in unit testing, foreign keys for one-to-many relationships aren't created. Here is my Equipment entity: pu...

Schema generation for maps in Hibernate

Hi there, I have a class Folder and a class File with a one-to-many relationship between them, implemented with a Map. Here is the hibernate mapping file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3...

Create nonclustered primary keys using NHibernate and SchemaExport

We're using SchemaExport via ActiveRecord. By default it generates a table like this: create table List ( Id UNIQUEIDENTIFIER not null, Name NVARCHAR(255) null, OwnerId UNIQUEIDENTIFIER null, primary key ( Id )) SQL Server then defaults to adding a clustered index for the primary key. But I want this to be nonc...

NHibernate SchemaExport: How to generate a meaningful unique key name?

When I use SchemaExport with SQL Server 2005, it generate unique key name like: UQ_Employees_03317E3D Hom can I generate a name like: UQ_Employees_Name? Even in SQL Server! ...

Which Oracle view contains all constraints together?

I'm trying to get CONSTRAINTS from user_objects table like this: select CASE object_type WHEN 'DATABASE LINK' then 'dblinks' WHEN 'FUNCTION' then 'functions' WHEN 'INDEX' then 'indexes' WHEN 'PACKAGE' then 'packages' WHEN 'PROCEDURE' then 'procedures' WHEN 'SEQUENCE' then 'sequences' WHEN 'TABL...

Suppress ORA-00942 errors in ddl create scripts

Say you generate ddl to create all your db tables etc via Hibernate SchemaExport etc. What you get is a script which starts with drop statements at the beginning. Not a problem, as I want this. But running this script produces a crapload of ORA-00942 errors running on an Oracle db. Since they're not really errors if the tables just...