Creating 1-N Relations

Topics: Administration, Core, Customizing Orchard, Writing modules
Apr 6, 2012 at 3:03 PM
Edited Apr 7, 2012 at 5:55 AM

I am New to Orchard. I was Following the Orchard Docs from here.

I have Followed it and Created the Module as explained in there. I am getting the module in modules link in admin panel also, the problem is that not getting it in the content types and also the the tables not getting created in Orchard.sdf(using sql express).Have read and tried the post with the  title Creating 1-N Relations but didn't worked for me.


Log file Contents:

 

2012-04-07 10:11:17,170 [10] NHibernate.AdoNet.AbstractBatcher - Could not execute command: UPDATE Szmyd_Orchard_Modules_Menu_CounterRecord SET ForItemId = @p0, InContextOfItemId = @p1, Count = @p2, Type = @p3, LastModified = @p4 WHERE Id = @p5
System.Data.SqlServerCe.SqlCeLockTimeoutException (0x80004005): SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout property. [ Session id = 4,Thread id = 4108,Process id = 6120,Table name = Szmyd_Orchard_Modules_Menu_CounterRecord,Conflict type = u lock (x blocks),Resource = RID: 1278:1 ]
   at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
2012-04-07 10:11:17,253 [10] NHibernate.Util.ADOExceptionReporter - SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout property. [ Session id = 4,Thread id = 4108,Process id = 6120,Table name = Szmyd_Orchard_Modules_Menu_CounterRecord,Conflict type = u lock (x blocks),Resource = RID: 1278:1 ]
2012-04-07 10:11:17,253 [10] NHibernate.Event.Default.AbstractFlushingEventListener - Could not synchronize database state with session
NHibernate.Exceptions.GenericADOException: could not update: [Szmyd.Orchard.Modules.Menu.Models.CounterRecord#2][SQL: UPDATE Szmyd_Orchard_Modules_Menu_CounterRecord SET ForItemId = ?, InContextOfItemId = ?, Count = ?, Type = ?, LastModified = ? WHERE Id = ?] ---> System.Data.SqlServerCe.SqlCeLockTimeoutException: SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout property. [ Session id = 4,Thread id = 4108,Process id = 6120,Table name = Szmyd_Orchard_Modules_Menu_CounterRecord,Conflict type = u lock (x blocks),Resource = RID: 1278:1 ]
   at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
   at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   --- End of inner exception stack trace ---
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session)
   at NHibernate.Action.EntityUpdateAction.Execute()
   at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
   at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
   at NHibernate.Engine.ActionQueue.ExecuteActions()
   at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
2012-04-07 10:11:17,369 [10] Orchard.ContentManagement.DefaultContentDisplay - GenericADOException thrown from IContentHandler by Szmyd.Orchard.Modules.Menu.Handlers.CountersHandler
NHibernate.Exceptions.GenericADOException: could not update: [Szmyd.Orchard.Modules.Menu.Models.CounterRecord#2][SQL: UPDATE Szmyd_Orchard_Modules_Menu_CounterRecord SET ForItemId = ?, InContextOfItemId = ?, Count = ?, Type = ?, LastModified = ? WHERE Id = ?] ---> System.Data.SqlServerCe.SqlCeLockTimeoutException: SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout property. [ Session id = 4,Thread id = 4108,Process id = 6120,Table name = Szmyd_Orchard_Modules_Menu_CounterRecord,Conflict type = u lock (x blocks),Resource = RID: 1278:1 ]
   at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
   at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   --- End of inner exception stack trace ---
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session)
   at NHibernate.Action.EntityUpdateAction.Execute()
   at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
   at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
   at NHibernate.Engine.ActionQueue.ExecuteActions()
   at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
   at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
   at NHibernate.Impl.SessionImpl.Flush()
   at Orchard.Data.Repository`1.Flush() in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\Repository.cs:line 118
   at Orchard.Data.Repository`1.Orchard.Data.IRepository<T>.Flush() in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\Repository.cs:line 52
   at Szmyd.Orchard.Modules.Menu.Services.CounterService.Increment(Int32 itemId, Int32 contextItemId, CounterType type, CounterStoreType store) in d:\MVC Projects samples\Orchard.Web.1.4.0\Orchard\Modules\Szmyd.Orchard.Modules.Menu\Services\CounterService.cs:line 75
   at Szmyd.Orchard.Modules.Menu.Handlers.CountersHandler.<>c__DisplayClass4.<.ctor>b__1(BuildDisplayContext ctx, AutoroutePart part) in d:\MVC Projects samples\Orchard.Web.1.4.0\Orchard\Modules\Szmyd.Orchard.Modules.Menu\Handlers\CountersHandler.cs:line 34
   at Orchard.ContentManagement.Handlers.ContentHandler.InlineTemplateFilter`1.BuildDisplayShape(BuildDisplayContext context, TPart instanc




 

Included all the .cs file in <compile> tag in RelationSample file.

 

Any help would be greatly appreciated,

Thanks & Regards,

Asif

Coordinator
Apr 7, 2012 at 6:12 AM

According to that stack trace, the error seems to be completely unrelated to the relationship tutorial. Seems like it;s Piotr's menu module that's causing trouble here.

Apr 7, 2012 at 7:29 AM
Edited Apr 7, 2012 at 7:31 AM

Thanks for replying,

I am using Szmyd.Orchard.Modules.Menu this module for creating a Menu and its submenu items that's working fine i don't understand why these log errors, but problem is with RelationSample module which i created from tutorial, i mentioned the url in previous post.

That's all i find log file which i posted in previous post...

Coordinator
Apr 7, 2012 at 8:00 AM

I don't know either, but it's right there in that stack trace.

Apr 7, 2012 at 8:18 AM

As i am learning creating modules the tutorial not working for me, What basic changes i need to make in Orchard v.1.4.0.0 to make tutorial example to work.Any pointers/links would be a great help.

Coordinator
Apr 7, 2012 at 8:41 AM

Try to disable the advanced menu module and see if it makes a difference.

Apr 7, 2012 at 9:49 AM
Edited Apr 7, 2012 at 9:49 AM

Cleared the log file, Disabled the advanced menu module and no success, no log errors too :(

Coordinator
Apr 8, 2012 at 9:01 AM

Are you still getting the same stack trace?

Developer
Apr 8, 2012 at 4:54 PM

Looks like an issue with the view counters and SQL Compact w/ NHibernate.

To keep the view counter incrementation atomic there are some locks applied. Working with SQL CE is a troublesome thing sometimes. Will try to investigate - haven't seen such issues previously.

@Bertrand Were there any important changes regarding NHibernate and/or SQL CE in 1.4? Will search the changesets, but maybe you already know about anything like that?

Coordinator
Apr 9, 2012 at 8:29 AM

I don't know.

Apr 16, 2012 at 6:27 AM

Are you still getting the same stack trace?

No, when i disabled the Advanced Menu module no log entries in Log file(empty).

 

sorry for late reply, Earlier i was using command line method of generating the module structure and using  webmatrix tool (not familiar with it), created the module using Visual studio used the class library approach in creating the module and the module working fine.

Thanks for constant support..

Apr 16, 2012 at 10:16 AM
Edited Apr 16, 2012 at 10:18 AM

Hello,

I'm getting similar errors in the log when I go to site admin / Modules / Installed. I'm not sure but it looks like the number of errors is equal to the number of modules displayed on the Installed tab.

The site was upgraded from 1.3 to 1.4 recently; all available module updates were installed.

All Orchard modules have version 1.4 except of these two:

  • Alias - Version: 1.0
  • Autoroute - Version: 0.8

 

Error:

WIN-MFSU55GLHUR :: ERROR :: RuntimeBinderException thrown from Action`1 by System.Action`1[[Orchard.DisplayManagement.Implementation.ShapeDisplayingContext, Orchard.Framework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null]]
Logger: Orchard.DisplayManagement.Implementation.DefaultDisplayManager
Thread: 5
Date: 2012-04-16 01:35:46,544
NDC: (null)

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot implicitly convert type 'Orchard.Modules.Models.ModuleEntry' to 'Orchard.ContentManagement.ContentPart'
  at CallSite.Target(Closure , CallSite , Object )
  at Orchard.DesignerTools.Services.WidgetAlternatesFactory.<Displaying>b__5(ShapeDisplayingContext displayedContext)
  at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.<>c__DisplayClassc.<Execute>b__5(Action`1 action) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 78
  at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in c:\Users\sebros\My Projects\Orchard\src\Orchard\InvokeExtensions.cs:line 19

May 8, 2012 at 2:22 PM

I often times find these lock errors produce a stack trace that has virtually nothing to do with what the problem ACTUALLY is.

A notable example I can think of is I had a lock error pop up in a module I was creating every time I tried to create a certain content type. The stack trace was a select for records from the blog module (I think it was post and comment counts but I could be wrong), likely from a background task run by it. My problem was really a column I had dropped in my database but the property was still present on my record class: so as that exception bubbled it's way up to the debugger the subsequent exceptions produced by that single failure eventually burried the exception that was the actually problem and provided me with the last piece of fallout from it. That's just one example, I have seen this more than a few times, and it's always something I did wrong.

So.. @Mdasif: Have you checked for any mismatches between your migration and your record classes? If that's not it I would look at other aspects of your selection and persistence logic, because a failure there is likely the REAL culprit here.