NHibernate Forge
The official new home for the NHibernate community

Mapping a view and Schema Export Workaround

Page Details

First published by:
Gustavo
on 09-05-2008
Last revision by:
Dario Quintana
on 12-16-2008
3 people found this article useful.
Article
Comments (4)
History (6)
100% of people found this useful

Mapping a view and Schema Export Workaround

NHibernate can easily map a View as any other Table.

This works as a charm, but it has a problem with Schema Export. Schema Export will detect the view as a table and will attempt to create the unexisting table.

A workaround for this is using <database-object> tag to Drop the unwillable table on creation, someting like:

<database-object> <create>DROP TABLE UnWantedTable</create> <drop /> </database-object>

An idea to avoid this workaround is having some hint to SchemaExport to indicate that this class should not enter in the Export ...

I opened this suggestion in this JIRA, you can vote for it if you also map your views and do not want the wrong creation of a table on export!

http://jira.nhibernate.org/browse/NH-1274

New FeatureCustomizing Schema Export with schema-action

 

 

Recent Comments

By: Tuna Toksoz Posted on 03-16-2009 17:25

Will Shaver has proposed a way to specify what not to export

nhjira.koah.net/.../NH-1274

By: Gustavo Posted on 12-16-2008 16:29

hooray for the new feature :)

By: Gustavo Posted on 10-17-2008 14:02

if the view already exists you are unit testing an existing DB...that's not good. You start from a blank DB and create all the entities. If you start with a blank DB as it is needed for unit tests, then the view doesn't exist.

By: Jose Ramirez Posted on 09-16-2008 10:40

<p>+1 for the jira issue</p>

<p>DROP TABLE doesn't solve the problem at all because generally the view already exists and you willl get an error when schemmaexport intents to create the homonym table</p>

View All
Powered by Community Server (Commercial Edition), by Telligent Systems