Hi,
I have developed an application locally and tested all functionality works as expected and everything does. When I deploy the application some funnies start happening such as an insert that worked locally stops working on the server (see error below). Locally I am developing against
full SQL Server 2005 but deployment works off SQL Express this is the only thing that I am aware of that may be causing an issue.
Any help is very much appreciated as I am stumped with this.
Thanks in advance,
Brendan
Please see the error message below:
-----------------------------------------------------------------------------------
Inner exception:
SqlException
Message:
Cannot insert the value NULL into column 'Id', table 'hughgrice.dbo.Painting'; column does not allow nulls. INSERT fails.
The statement has been terminated.
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) in D:\@Repository\NHibernate\nhibernate\src\NHibernate\AdoNet\AbstractBatcher.cs:line 191
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session) in D:\@Repository\NHibernate\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 2301
--------------------------------------------------------------------------------
NHIBERNATE Web.Config ENTRY
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<!-- This is the System.Data.dll provider for MSSQL Server -->
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">
Server=(local);initial catalog=hughgrice;Integrated Security=SSPI
<!--Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\hughgrice.mdf;Integrated Security=True;User Instance=True-->
</property>
<property name="show_sql">True</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="use_outer_join">true</property>
<property name="command_timeout">444</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="adonet.wrap_result_sets">False</property>
<property name="connection.release_mode">on_close</property>
</session-factory>
</hibernate-configuration>
--------------------------------------------------------------------------------
PAINTING HBM.XML
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<class name="HughGRice.Portal.Core.Models.Painting, HughGRice.Portal.Core" table="Painting">
<id name="Id" type="Int32" unsaved-value="0">
<column name="Id" length="4" sql-type="int" not-null="true" unique="true" index="PK_Painting"/>
<generator class="native" />
</id>
<property name="Name" type="String">
<column name="Name" length="100" sql-type="nvarchar" not-null="true"/>
</property>
<property name="Description" type="String">
<column name="Description" length="200" sql-type="nvarchar" not-null="false"/>
</property>
<property name="Media" type="String">
<column name="Media" length="100" sql-type="nvarchar" not-null="false"/>
</property>
<property name="Size" type="String">
<column name="Size" length="20" sql-type="nvarchar" not-null="false"/>
</property>
<property name="Price" type="Decimal">
<column name="Price" length="8" sql-type="money" not-null="false"/>
</property>
<property name="Sold" type="Boolean">
<column name="Sold" length="1" sql-type="bit" not-null="false"/>
</property>
<property name="Photo" type="String">
<column name="Photo" length="50" sql-type="nvarchar" not-null="false"/>
</property>
<many-to-one name="Gallery" class="HughGRice.Portal.Core.Models.Gallery, HughGRice.Portal.Core">
<column name="GalleryId" length="4" sql-type="int" not-null="false"/>
</many-to-one>
<many-to-one name="PaintingType" class="HughGRice.Portal.Core.Models.PaintingType, HughGRice.Portal.Core">
<column name="PaintingTypeId" length="4" sql-type="int" not-null="false"/>
</many-to-one>
</class>
</hibernate-mapping>
|