Code Monkey home page Code Monkey logo

Comments (22)

andidev avatar andidev commented on July 17, 2024 1

I also successfully created a many to one relationship to the User entity with the following entity json:

{
    "relationships": [
        {
            "relationshipId": 1,
            "relationshipName": "user",
            "otherEntityName": "user",
            "relationshipType": "many-to-one",
            "otherEntityField": "id"
        }
    ],
    "fields": [
        {
            "fieldId": 1,
            "fieldName": "name",
            "fieldType": "String"
        }
    ],
    "changelogDate": "20150822135227",
    "dto": "no",
    "pagination": "no"
}

both mvn test and grunt test works and I can update the user relationship in the gui.

Could you please provide the json files for the failing tests so I can try to fix them?

from jhipster-uml.

kalvarez2 avatar kalvarez2 commented on July 17, 2024

On the entitiescreator.js file, lines 201-208. I understand the current documentation says that User is a reserved entity and any owning relationships will be ignored, but it also says that relationships to the user entity would be honored.

Is that check for the injected field type removing any relationship to the user?

from jhipster-uml.

kalvarez2 avatar kalvarez2 commented on July 17, 2024

Update: I removed that check locally, keeping the check for the class, but removing the check for the type, and that fixes my problem,at least for OneToOne relationship, no idea what other weird behavior that might introduce...

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

The fix I'll commit only works for One-to-One relationships, as other relationships will break JHipster's tests (reproduced with and without JHipster-UML's JDL).
So, for now, I'll push the fix for the One-to-One. If the other types or relationships are supported, then I'll keep adding them.

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

(Partially) Fixed by 4837b24.

from jhipster-uml.

andidev avatar andidev commented on July 17, 2024

Many to one and many to many is supported and works in jhipster as it is today. Just tested it yesterday.

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

Well, I just tested it with the User class, and the tests fail. I took @kalvarez2's example, it worked (because it's a O2O). However, the O2M and the M2M fail when testing the app.

from jhipster-uml.

andidev avatar andidev commented on July 17, 2024

I successfully created a many to many relation with latest jhipster-uml 1.3.2 which generated the following enity.json:

{
  "relationships": [
    {
      "relationshipId": 1,
      "relationshipName": "aUser",
      "relationshipFieldName": "aUser",
      "otherEntityName": "user",
      "relationshipType": "many-to-many",
      "otherEntityField": "id",
      "ownerSide": true
    }
  ],
  "fields": [],
  "changelogDate": "20150822131836",
  "dto": "no",
  "pagination": "no"
}

mvn test and grunt test both pass.

Is it only Many to one relationships that fail?

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

The code I got looks like yours... Gotta recheck. I'll post the code as soon as I get back to my computer.

from jhipster-uml.

andidev avatar andidev commented on July 17, 2024

By the way, just to be clear, I used the current master branch of jhipster. Though I think it works with the latest release as well.

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

Just got back. I'm using the latest code available of both JHipster and JHipster-UML.
The M2M, the O2O and the M2O work, but not the O2M, which is just crazy because adding the last entity makes my tests fail (all of them, not just the ones for the last entity).

Here are all the .json, hope you can make some sense out of this mess.
TestA.json:

{
    "relationships": [
        {
            "relationshipId": 1,
            "relationshipName": "user",
            "otherEntityName": "user",
            "relationshipType": "many-to-one",
            "otherEntityField": "id"
        }
    ],
    "fields": [],
    "changelogDate": "20150822193205",
    "dto": "no",
    "pagination": "no"
}

TestB:

{
    "relationships": [
        {
            "relationshipId": 1,
            "relationshipName": "user",
            "otherEntityName": "user",
            "relationshipType": "many-to-many",
            "otherEntityField": "id",
            "ownerSide": true
        }
    ],
    "fields": [],
    "changelogDate": "20150822193343",
    "dto": "no",
    "pagination": "no"
}
{
    "relationships": [
        {
            "relationshipId": 1,
            "relationshipName": "user",
            "otherEntityName": "user",
            "relationshipType": "one-to-many",
            "otherEntityRelationshipName": "testC"
        }
    ],
    "fields": [],
    "changelogDate": "20150822193437",
    "dto": "no",
    "pagination": "no"
}

I see an error in the JSON generated from JHipster-UML however, the relationshipFieldName shouldn't be there for the M2M.

from jhipster-uml.

andidev avatar andidev commented on July 17, 2024

I'm not sure but I think that test C fails cause one to many relationship (where the user is the owner) with the user entity is not supported by jhipster.

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

That should be the standard behavior... however, how come my TestC entity is not the owner of the relationship? If I set a O2M from TestC to User, then TestC should be the owner, right? Unless I'm missing some convention here...

from jhipster-uml.

andidev avatar andidev commented on July 17, 2024

I think it's the other way around. The Many entity will be the owner. According to the docs the many entity is the right one.

relationship OneToMany{
  One{many} to Many{one(<otherEntityField>)}
}

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

If that's the case, there's some weird logic involved...
In JDL, the first is the owner (that's why we chose to say <XXX> to <YYY>). If in JHipster, when creating a O2M, the current entity is not the owner, then something's wrong, in my opinion.

I clearly don't understand the logic behind it, or there's a big misunderstanding here.

from jhipster-uml.

andidev avatar andidev commented on July 17, 2024

In jhipster when creating an O2M the current entity is never the owner. The many entity is always the owner in a O2M relationship.

You say that in jdl that the first entity is always the owner. That is not true. It is the first entity that is the owner for M2O, O2O and M2M relationships but not the O2M. In fact te first one could never always be the owner since the O2M is the inverse of the M2O relationship.

Though I am not 100% sure of the owner definition. I see it as the entity that has the gui for changing the relationship id's.

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

That's strange. The doc says otherwise, and (until now) I thought the same. Anyway, my bad.

from jhipster-uml.

kalvarez2 avatar kalvarez2 commented on July 17, 2024

Guys, my two cents if i may...
-it makes sense not to create a list of other entities in a class by
default. It might be harder to optimize later... it is one lesson I have
learned. So it makes sense that jhipster doesnt do it. I am perosnally ok
with that.

-i understand user is an special entity and changes are not alowed, but
having a reference to user in a clas produced by a o2o or m2o seems like a
very usefull feature.

I am a software developer with some experience. I have found jhipster and
jml both very usefull and would like to give back some of my time, anything
you guys would like me to handle?

On Sun, Aug 23, 2015, 2:45 PM Mathieu ABOU-AICHI [email protected]
wrote:

That's strange. The doc says otherwise, and (until now) I thought the
same. Anyway, my bad.


Reply to this email directly or view it on GitHub
#45 (comment)
.

from jhipster-uml.

andidev avatar andidev commented on July 17, 2024

@MathieuAA
I think one reason for the confusion may be that jhipster never asks for the owner side when creating a one-to-many and many-to-one relationship. The ownerSide property is not even set in the entity json for that kind of relationships. Instead the ownerSide is determined by the relationship type.

@kalvarez2
PR improvements are always welcome, not sure what needs to be done here though =)

from jhipster-uml.

kalvarez2 avatar kalvarez2 commented on July 17, 2024

great work guys!
@andidev
is there a list of requests somewhere? How about supporting comments on jdl, I have one with 16 entities and the relationships are hard to folow with no comments, I was looking at the parser that was generated, seems posible to add a new rule to ignore comments as white space with a regex?
Again, is there a "nice to have list"?

from jhipster-uml.

andidev avatar andidev commented on July 17, 2024

I think there is no list other than the issue list though I am not the author of jhipster-uml so you should probably ask @CarlKlagba or @MathieuAA for this.

from jhipster-uml.

MathieuAA avatar MathieuAA commented on July 17, 2024

For comments on JDL, I or @CarlKlagba will work on that very soon, and we'll parse comments from XMI too.
And as @andidev said, there's no list. People just drop by and post an "issue" on GitHub, which is bad enough... They should have renamed it "ticket" instead.

from jhipster-uml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.