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

Junction table object name error.

3 Answers 45 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Kiger
Top achievements
Rank 1
Michael Kiger asked on 31 Mar 2010, 05:04 PM

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?

3 Answers, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 01 Apr 2010, 03:09 PM
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.
0
Michael Kiger
Top achievements
Rank 1
answered on 01 Apr 2010, 04:28 PM

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.

0
Alexander
Telerik team
answered on 06 Apr 2010, 04:30 PM
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.
Tags
General Discussions
Asked by
Michael Kiger
Top achievements
Rank 1
Answers by
Serge
Telerik team
Michael Kiger
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or