Unable to create Domain Method Return Shape manually

8 posts, 0 answers
  1. Kurniadi
    Kurniadi avatar
    22 posts
    Member since:
    Jan 2006

    Posted 14 May 2012 Link to this post

    Hi, I have same problem getting Result Shape automatically from Stored Procedure editor as described in this post http://www.telerik.com/community/forums/orm/databases/error-with-retrieve-result-shape.aspx. My stored procedures also use temp table. I tried following the suggested workaround given on that other post, however on the domain model explorer I could not find option to add new Domain Method Return Shape. When I right click on that node all I get is Delete All option. What I have done is I created a new Domain Class as I already know what the stored procedure is going to return. Then I was able to use Store Procedure editor and selected persitance type as the Stored Procedure's return shape using the model I just created. All generated nicely. When I ran my app however, I received an error:

    Invalid object name 'voa_keygen'. Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'voa_keygen'.
    at Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.executeQuery(String sql)
    at OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator.IsCached(Connection con, RelationalKeyGeneratorInfoCache infoCache, String tab, String kCol, String vCol, String key, Boolean& ret)
    at OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator.init(String className, RelationalTable theClassTable, Connection con, RelationalKeyGeneratorInfoCache relationalKeyGeneratorInfoCache)
    at OpenAccessRuntime.Relational.RelationalStorageManagerFactory.init(Boolean full)

    My guess was this happened because I did not have primary key in my domain class model. So I went ahead and edited my result shape domain class and used one of my fields as identity which it is. Now my app returned a different error message:

    Mapping the result to instances of the class 'Namespace.Object.SearchResult' failed because the required primary key column 'risk_id' is not present

    The name of my identity field is RiskId which matches the field name returned by the stored procedure. I don't understand why it is looking for risk_id.
    Please can someone help point out what I have done wrong? Do I need to map each field returned by stored procedure to the domain class's properties manually? When I clicked on the new Class diagram on the diagram area, the Mapping Details Editor at the bottom showed no mappings and I could not edit anything there to create new mappings.
  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 15 May 2012 Link to this post

    Hi Rudy,


    1. This table “voa_keygen” is required by OpenAccess when one or more classes in the model use the HighLow KeyGenerator (default Identity Mechanism). Telerik OpenAccess ORM uses the "voa_keygen" table to store some system values.

    You could either change the persistent type’s identity mechanism to DatabaseCalculated or use the Update Database from Model wizard to create this table in the database.

    2. The error indicates that the columns returned by the query do not contain the primary key columns of the type you are trying to map the result to. It seems that the persistent capable type is not mapped to a table. In order to avoid this issue you could do the following steps:
    - Right click on the class;
    - Select Map to Table setting;
    - Save the model and rebuild;

    Hope that helps.

    All the best,
    Damyan Bogoev
    the Telerik team
    Follow @OpenAccessORM Twitter channel to get first the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. Kurniadi
    Kurniadi avatar
    22 posts
    Member since:
    Jan 2006

    Posted 15 May 2012 Link to this post

    Hi Damyan,
    With regards to point 2, I do not have a table to map this custom return shape to. It is supposed to be a custom class for the purpose of delivering stored procedure result shape.
    I can see now on EditTable mapping dialog where the name risk_id comes from. Apparently almost all names that I have defined in the class I created manually have its field names changed. For example RiskId becomes risk_id, Number becomes numbr (missing e). Year becomes yr. These names are not editable unfortunately. Do you know where they are stored and how I can fix those names?
  5. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 16 May 2012 Link to this post

    Hi Rudy,


    The column names are calculated by the default mapping mechanism of the product. It will calculate the table and column names based on default naming strategy.

    You could avoid using the generated names by explicitly mapping the class to a table using the Table Editor. There you could modify the column names.

    Hope that helps.

    All the best,
    Damyan Bogoev
    the Telerik team
    Follow @OpenAccessORM Twitter channel to get first the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  6. Kurniadi
    Kurniadi avatar
    22 posts
    Member since:
    Jan 2006

    Posted 16 May 2012 Link to this post

    Hi Damyan, I think we are only going around in circles. As I have already mentioned, I do not have a table to map this custom class to. It was created for the purpose of returning stored procedure result shape. Can you explain how I can create custom class for my stored procedure result shape? Please dont tell me to use stored procedure editor, because this is where the issue started if you have read my original post.
  7. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 17 May 2012 Link to this post

    Hello Rudy,


    1. The easiest solution to this problem is to create a view in the database that matches the stored procedure result shape and map this view to a persistent capable type using the Update from Database wizard. Later on map the stored procedure result to the newly added persistent type.

    2. You could achieve this goal by doing the following steps:
    • Create the persistent class, which matches the stored procedure result shape, using the visual designer;
    • Map the stored procedure result to this class using the Stored Procedure editor by selecting it from the Persistent Types combo box;
    • Create a new class which contains the newly created persistent class definition and remove this class from the designer;
    • Save the diagram;
    • Open the OpenAccess Model Explorer window;
    • Expand the Domain Method Return Shapes node and select the new return shape;
    • Press F4 to open the Properties Window grid for the select return shape;
    • Change the Domain Method Type from PersistentType to CustomShape;
    • Rebuild the project;

    Hope that helps.


    Greetings,
    Damyan Bogoev
    the Telerik team
    Follow @OpenAccessORM Twitter channel to get first the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  8. Alois
    Alois avatar
    5 posts
    Member since:
    Jun 2012

    Posted 20 Aug 2012 Link to this post

    Hello!

    I have the same issue. Is there anything news in the actual release.

    Although I tried to map the procedure to a view, I have not get it.

    A.Kleine
  9. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 21 Aug 2012 Link to this post

    Hello Alois,

    I was able to map a stored procedure result to a database view using the Stored Procedure editor. Could you please provide us with some additional details in order to investigate the issue further?
     
    We are looking forward to hearing from you.


    Kind regards,
    Damyan Bogoev
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Back to Top
DevCraft banner