add new record - HELP!

11 views
Skip to first unread message

scottl2001

unread,
Jun 24, 2011, 10:17:47 AM6/24/11
to Castle Project Users
I've got a situation I've encountered before, and am still trying to
resolve:

When I'm trying to add a record to the database with castle, it will
no longer allow me to do so, (stack trace provided below)

In the past, I've alleviated the problem by doing an
ActiveRecordStarter.CreateSchema(); after initializing the classes,
but was never able to do this without losing all of the data.

I'm no longer in a position where I can lose the data when re creating
the schema. Is there a way to re crate the schema without losing all
of the data? Using NHibernate and MS SQL Server


***********************************

Message:
Could not perform Create for Run
Exception Trace:
at Castle.ActiveRecord.ActiveRecordBase.InternalCreate(Object
instance, Boolean flush)
at Castle.ActiveRecord.ActiveRecordBase.Create(Object instance)
at Castle.ActiveRecord.ActiveRecordBase.Create()
at RunApplications.Data.Providers.BaseProvider`1.Add(T record) in C:
\development2\In Progress\RunApplications\RunApplications.Data
\Providers\BaseProvider.cs:line 25
at RunProcessor.GroupedImport.Execute(RunImport import) in C:
\development2\In Progress\RunApplications\RunProcessor\ImportEngine
\GroupedImport.cs:line 46
at RunProcessor.ImportEngine.Execute(RunImport import) in C:
\development2\In Progress\RunApplications\RunProcessor\ImportEngine
\ImportEngine.cs:line 28
at RunProcessor.Processor.ProcessImports(ImportCollection imported,
String filename) in C:\development2\In Progress\RunApplications
\RunProcessor\Processor.cs:line 133

Inner Exception:
could not insert: [RunApplications.Data.Models.Run][SQL: INSERT INTO
RunMaster (Version, RunNumber, CompanyID, Ink1, Ink2, Initials,
GoSetCode, RunHeaderType, Plant, StockItem, RunQuantity,
SpillageQuantity, RushPriority, NumberUp, UniqueOrders, DueOrders,
ServiceLevel, StatusID, GroupedDate, DateAdded, PressDate,
EarliestShipDate, LastUpdated, IsLaserProofed, OnHold, HoldReason,
DepartmentTrack, RunInstructions, ReportID, StagingID,
StagingTicketGeneratedOn, LastUpdatedBy, ProductTypeID, RunClassID,
GroupTypeID) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
Inner Exception Trace:
at
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[]
fields, Boolean[] notNull, SqlCommandInfo sql, Object obj,
ISessionImplementor session)
at
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[]
fields, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledIdentityInsertion.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.DoSave(Object theObj, EntityKey key,
IEntityPersister persister, Boolean replicate, Boolean
useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id,
IEntityPersister persister, Boolean useIdentityColumn, CascadingAction
cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object
obj, CascadingAction action, Object anything)
at NHibernate.Impl.SessionImpl.Save(Object obj)
at Castle.ActiveRecord.ActiveRecordBase.InternalCreate(Object
instance, Boolean flush)
}

*************************************************

scottl2001

unread,
Jun 24, 2011, 10:50:17 AM6/24/11
to Castle Project Users

**** NOTE: ***
I have been able to inserrt records into this table in the past, but
no longer can do so. No idea what I dod to make it mad

scottl2001

unread,
Jun 24, 2011, 12:17:15 PM6/24/11
to Castle Project Users

One other note, I can update to the same table through a provider,
just cannot add to the exact same table. Doesn't make sense!



On Jun 24, 9:17 am, scottl2001 <scottlackey2...@yahoo.com> wrote:

Markus Zywitza

unread,
Jun 24, 2011, 12:58:53 PM6/24/11
to castle-pro...@googlegroups.com
What happens if you copy/paste the SQL in SSMS and insert a record there?

Do you use assigned IDs, are they generated by NH or the database?

--Markus

scottl2001

unread,
Jun 24, 2011, 3:06:09 PM6/24/11
to Castle Project Users

SQL is fine. IDs are Identity columns. It's as though Castle wants
me to do another ActiveRecordStarter.CreateSchema, but I've never been
able to do that without losing all of the existing data. Any ideas???

Odd thing is, I can update through Provider.Update(classname) but
adding via Provider.Add(classname) give me the above error...
Reply all
Reply to author
Forward
0 new messages