Junction table object name error.

Thread is closed for posting
4 posts, 0 answers
  1. Michael Kiger
    Michael Kiger avatar
    2 posts
    Member since:
    Mar 2010

    Posted 31 Mar 2010 Link to this post

    I am working with a project that was setup using forward mapping.  There is a many-to-many relationship between user roles and menu items; the database tables are user_role, mnu and user_role_mnu.  The classes in the project are UserRole and Menu; there is not a class for the junction table since forward mapping was used.

     

    I added a field to the junction table to control the level of access.  My intent was to create the junction table class and use it to control a user’s access to the menu items.  I ran the reverse mapping tool and generated the junction table class UserRoleMnu.  When running the code, the following exception is thrown when trying to populate the Menu IList in the UserRole class:  “Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'user_role_mnu2'. Statement(s) could not be prepared”.  The call stack is deep into ORM code.

     

    My guess is ORM provides its own dynamic implementation of the junction table class and names it “user_role_mnu”.  Since the reverse mapping created a junction class in my project, ORM now has a class name conflict.

     

    Does anyone know how to resolve this error?

  2. Serge
    Admin
    Serge avatar
    375 posts

    Posted 01 Apr 2010 Link to this post

    Hi Michael Kiger,

    Normally the forward and reverse mapping approaches should not be mixed, as this could lead to problems of that type. I would suggest you to undo your changes in the code to the point where you performed the reverse mapping and follow this article. It explains how to add fields to the join table while using forward mapping. Basically the m:n relation has to be split to two 1:n relations. You may also have to delete your database in order for OpenAccess to create it with the new configuration. Hope that helps.

    Kind regards,
    Serge
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Michael Kiger
    Michael Kiger avatar
    2 posts
    Member since:
    Mar 2010

    Posted 01 Apr 2010 Link to this post

    Thanks.  I found the article yesterday, backed out the reverse mapping changes and am now making the forward mapping changes.

     

    It is unfortunate forward mapping and reverse mapping are implemented differently.  Reverse mapping provides the benefit of showing all the mapping information in the reversemapping.config file.  Forward mapping performs its mapping in the ORM code based on a set of rules, so there is not a configuration containing the bulk of the mapping information.  If forward mapping created a mapping file based on its rules, the two mapping approaches could be mixed and more mapping flexibility would be available to the developer.

     

    Thanks again for your assistance.

  4. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 06 Apr 2010 Link to this post

    Hello Michael Kiger,

    We are aware of that there are some cases when both forward and reverse mapping can be used. Mixing the two approaches will be possible when we provide forward mapping capabilities in the visual designer as it works with a single metadata model, not with one forward mapped and one reverse mapped. In the meantime please use the methods that we already discussed.

    Regards,
    Alexander
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top