Editing inverse relation in SpringDSL does not reflect in generated code

  1. MyEclipse IDE > Spring Development

This topic contains 7 replies, has 2 voices, and was last updated by  support-tony 4 years, 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #523387 Reply

    Luis Pedro


    I have a scaffolded Spring application. After a recent DB modification and a rescaffolding, there must have been a little bug that created an ill-defined relation in one of the Spring DSL datatypes. Namely, the inverse relation is not the right one.
    I want to avoid rescaffolding again, because it takes a long time for me (see previous messages in the forum), so I went and edited the inverse relation name in the Spring DSL datatype, then I did a “Generate artifacts from Spring DSL” from the edited datatype.
    However, the generated java file still has the old inverse relationship – it is not taking into account my modification. I also tried removing the java file and regenerating it from scratch, but it yelded the same results.
    Is there anything I am not getting about how this is supposed to be done?

    Thank you. Here below a few more details that might be useful for your reference.

    The database has a table fundstructureelement, primary key is its id column.
    Then there is a masterfeeder table, which has 3 columns: id, master and feeder. The primary key is id, while master and feeder are foreign keys to the id of fundstructureelement.

    The generated SpringDSL datatype for fundstructureelement, Fundstructureelement.datatype, shows that there are two relations:
    masterfeedersForMaster --> Inverse name: fundstructureelementByMaster (this looks fine)
    masterfeedersForFeeder --> Inverse name: fundstructureelementByMaster (this is not right: the inverse name should be fundstructureelementByFeeder)

    Note that the Masterfeeder.datatype correctly has the following relations:
    fundstructureelementByMaster --> Inverse name: masterfeedersForMaster
    fundstructureelementByFeeder --> Inverse name: masterfeedersForFeeder

    What I did was going to Fundstructureelement.datatype, click on the inverse name for masterfeedersForFeeder, and select fundstructureelementByFeeder in the dropdown (I have both fundstructureelementByMaster and fundstructureelementByFeeder as possible proposed values).
    Then I did the “Generate artifacts from Spring DSL”.

    However in the Fundstructureelement.java file that is generated I have the following:

    At this point, I have one error in the Problems view:
    fundstructureelementByMaster must be referenced by its inverse relationship (referring to Masterfeeder.datatype)

    And if I run the Spring application, it fails to start with:

    • This topic was modified 4 years, 2 months ago by  Luis Pedro.
    #523389 Reply

    Luis Pedro

    PS: I might add that I tried manually changing the mappedBy attribute in the Java file, but the result is the same.

    #523399 Reply

    Luis Pedro

    Ok, I had a litte progress; after manually editing the Java to reflect the modification in the datatype, I removed the app from tomcat and republished it from scratch, which allowed me to at least run it.

    However the error in the Problem view stays, and the fact that my DSL modification were not reflected in the code is still an issue. How can I find a way to do this without errors popping up and in a more reliable way?

    #523757 Reply



    This looks like a bug and I’ve filed a problem report for the developers to investigate. It looks as though an associated XML file is not being generated correctly and not being updated when you changed the mapping to the correct one.

    Please try this workaround. Open your project folder in a system explorer (right click on the project and select Open in Explorer). Make sure you are viewing hidden files as you will need to look for the “.springDSL” folder. Under there are the folders that correspond you your package name, down to your domain package. You’ll find the files fundstructureelement.datatype and fundstructureelement.datatypebinding. You’ve already corrected the first, via MyEclipse but you’ll need to manually edit the second to make a similar correction. Once that is done, save the file and then go back to MyEclipse and refresh the project to pick up externally made edits. Now, when you Generate Artifacts from Spring DSL, you should get the correctly generated java file.

    The edits to the datatypebinding file can be made inside MyEclipse, via the Navigator view, but can lead to some unwanted settings that are tedious to undo, so it’s probably easier to made the edits outside.

    Please let us know how you get on.

    #523954 Reply

    Luis Pedro

    Hello Tony,

    A-ha, I see. As a matter of fact, the datatypebinding _did_ miss the correction. I can’t test this now, but as a rescaffolding is coming up soon anyway, I will make sure to give that a shot.
    Thanks, best.

    #524053 Reply



    Good; it looks like that is the underlying problem, when trying to manually correct the mapping. Please let us know how you get on when needing to do the correction again.

    Apologies for the inconvenience.

    #524388 Reply

    Luis Pedro


    I can confirm the workaround (editing the .datatypebinding by hand, refreshing, and regenerating the class from the DSL) works indeed.
    Remains to be seen, why the inverse relationships name were generated wrong in the first place. As I see it, this seems a separate bug. Is there a problem when a table has two separate foreign keys referencing the same parent table?
    I seem to recall that I had similar problems with other relationships in my DB in the past, when I had this same kind of pattern; only, I had not identified this inverse relationship generation problem at the time, so I had worked around this by removing foreign keys and ensuring consistency in the code instead. This might have been the cause those other times as well. It may be worth having a look at that too.

    #524587 Reply



    Thanks for letting us know that the workaround works for you. Yes, indeed, looking back, we have had a similar issue but not for someone working with Spring DSL. I have added further information to the bug (which may be two bugs, as you say) to help developers track this down.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Editing inverse relation in SpringDSL does not reflect in generated code

You must be logged in to post in the forum log in