This is a migrated thread and some comments may be shown as answers.

Exception on object insertion when using DatabaseServerCalculated IdentityMechanism with Firebird

5 Answers 120 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
H
Top achievements
Rank 1
H asked on 13 Mar 2013, 08:27 PM
We are currently using OpenAccess Free Edition version 3.5 with Firebird Server version 2.1 and Firebird DotNet Client version 2.7.0.0 in Visual Studio 2010.

I followed this tutorial to map Firebird ID generator with Telerik :
http://www.telerik.com/help/openaccess-orm/database-specifics-firebird-auto-inc-columns.html

When I set IdentityMechanism to DatabaseServerCalculated I get the following exception when trying to insert an object into the database:
Telerik.OpenAccess.Exceptions.DataStoreException was caught
  Message=Insert of '2141609161-' failed: System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'FirebirdSql.Data.FirebirdClient.FbParameter'.
   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
   at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
INSERT INTO "PRODUCT" ("DESCRIPTION", "NAME", "TYPE", "TYPE_TEXT", "USE_QUANTITY") VALUES (?, ?, ?, ?, ?) returning "ID"
(set event logging to all to see parameter values) System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'FirebirdSql.Data.FirebirdClient.FbParameter'.
   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
   at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
  Source=Telerik.OpenAccess
  CanRetry=false
  StackTrace:
       at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
       at Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x)
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalCommit(Boolean phase)
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
       at Telerik.OpenAccess.RT.EnlistableObjectScope.CommitChanges()
       at Telerik.OpenAccess.OpenAccessContextBase.SaveChanges(ConcurrencyConflictsProcessingMode failureMode)
       at Telerik.OpenAccess.OpenAccessContextBase.SaveChanges()
       at GestionSoumissionTelerik.Database.InsertProduct(PRODUCT product) in D:\Visual Studio\Projects\GestionSoumissionTelerik\Database.cs:line 74
  InnerException: System.InvalidCastException
       Message=Unable to cast object of type 'System.Int32' to type 'FirebirdSql.Data.FirebirdClient.FbParameter'.
       Source=Telerik.OpenAccess.Runtime
       StackTrace:
            at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
            at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
            at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
       InnerException: 

_______________________

If I set IdentityMechanism to Default, the record is correctly inserted into the database but the object becomes corrupted (unusable) after insertion. I would like to use IdentityMechanism DatabaseServerCalculated to get the generated Id from Firebird and use the object after insertion. Unfortunately this is not possible because when using DatabaseServerCalculated Telerik throws the exception above on insert and fail to insert the record in the database.

5 Answers, 1 is accepted

Sort by
0
H
Top achievements
Rank 1
answered on 14 Mar 2013, 08:24 PM
I found the solution to this bug, previously Firebird (1.5) had 32 bit GEN_ID now Firebird (2.1) has 64 bit GEN_ID.

However I have a new exception I'll try to find a solution for:

Table unknown

voa_keygen

0
H
Top achievements
Rank 1
answered on 14 Mar 2013, 08:30 PM
OK that was a fast one, I just had to set Identity=true on the ID field.

But now I'm back at square one, when inserting an object in database the object becomes corrupted event though I did set IdentityMechanism to DatabaseServerCalculated and have no exception.
0
Thomas
Telerik team
answered on 18 Mar 2013, 01:59 PM
Hi,

do you use a long field now to hold the identity value? I tried here with the newest version and Autoinc and found no such issue.

Regards,
Thomas
the Telerik team
OpenAccess ORM Q1 2013 is out featuring Multi-Diagrams, Persistent Data Stream Support and much more. Check out all of the latest highlights.
0
H
Top achievements
Rank 1
answered on 18 Mar 2013, 04:00 PM
Yes we use a Int64 for ID field and IdentityMechanism DatabaseServerCalculated .
I also tested with the latest telerik version, same results.

The object is inserted into database but after insert the object is throwing nosuchobject exception.
Not sure what you mean by AutoInc though, I haven't seen this specific setting.

 I took a screenshot of object after insertion:
http://i45.tinypic.com/2m60u8z.jpg
0
Thomas
Telerik team
answered on 19 Mar 2013, 05:43 PM
I just retried with the latest version of the driver (3.0.2) and VS2012 and it worked.
Please open the .rlinq file as XML and check the ID fields KeyGenerator setting. There must be something like keygenerator="autoinc" there. Please note also that you need to either have a trigger or to generate it via the database schema update.
For more information please see here http://www.telerik.com/help/openaccess-orm/database-specifics-firebird-auto-inc-columns.html .

Regards,
Thomas
the Telerik team
Free Webinar: OpenAccess Integration in Sitefinity. SIGN UP NOW.
Tags
Data Access Free Edition
Asked by
H
Top achievements
Rank 1
Answers by
H
Top achievements
Rank 1
Thomas
Telerik team
Share this question
or