Empty Abstract Base Class with TargetPerEntity - Possible?

Posts   
 
    
kds_chris
User
Posts: 2
Joined: 19-Jan-2009
# Posted on: 19-Jan-2009 21:38:01   

LLBLGen Pro version 2.6 + buildnr (latest - downloaded today - 2009-01-19) Runtime Library File Version: 2.6.8.1211 Adapter Template - VS 2008 Professional MS Access DB 2007

All,

Thank you in advance for your help.

We are having an issue when creating new leaf entities with the adapter template. We are using TargetPerEntity for inheritance.

Our database schema involves abstract base classes, many times consisting of nothing but an Id field, and concrete classes that are derived from those classes.

When we try to add a concrete entity, we get an error:

SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryConstructionException was unhandled Message="The insert query doesn't contain any fields." RuntimeBuild="12112008" RuntimeVersion="2.6.0.0" Source="SD.LLBLGen.Pro.DQE.Access.NET20" StackTrace: at SD.LLBLGen.Pro.DQE.Access.DynamicQueryEngine.CreateSingleTargetInsertDQ(IEntityFieldCore[] fields, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, Dictionary2& fieldToParameter) at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateInsertDQ(IEntityFieldCore[] fields, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateInsertDQ(IEntity2 entityToSave, IFieldPersistenceInfo[] persistenceInfoObjects) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateQueryForEntityToSave(Boolean insertActions, EntityBase2 entityToSave, IPredicateExpression updateRestriction, InheritanceHierarchyType typeOfHierarchy, IFieldPersistenceInfo[] persistenceInfoObjects) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List1 queueToPersist, Boolean insertActions, Int32& totalAmountSaved) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave) at kds.assetComplianceSuite.testApp.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\lp\My Documents\LLBLGen Pro Projects\kds.assetComplianceSuite\kds.assetComplianceSuite.testApp\Form1.vb:line 15 at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at kds.assetComplianceSuite.testApp.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

We have already figured out that, as a workaround, we can add an unused field to the abstract base class and set it to null when creating the new instance of the concrete class.

However, since it's common, in our schema, to have a base class without any fields itself, do we always have to have these unused fields to avoid this error?

Thank you.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Jan-2009 06:20:46   

Hi Chris,

Please post the relevant code where you are adding that concrete entity. Also the generated sql, when available.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 20-Jan-2009 09:54:54   

What you want isn't really supported on access. The thing is that you want to save an entity into a table with just an identity field, which leads to a query like: INSERT INTO table () VALUES ()

as there are no values to save.

SQL Server has the feature that one can specify 'default' in the INSERT statement which makes it possible to execute such a query, so it is supported on sqlserver, but not on access.

Frans Bouma | Lead developer LLBLGen Pro
kds_chris
User
Posts: 2
Joined: 19-Jan-2009
# Posted on: 22-Jan-2009 23:33:11   

Thank you both for responding so promptly.

I have decided to take a path that does not require the database to handle Id creation.

Thus, the problem no longer exists.

Thank you again.