Search code examples
springentityrelationshipjhipsterjdl

Jhipster - JDL studio - relationship to User


I want to create an entity (called StudentInfo) that has a one-to-one relationship to the User entity (generated my jhipster). How can I do this using JDL-studio ? Do I just declare a relationship to the User like so :

relationship OneToOne {
    StudentInfo{user} to User
}

Will jhipster recognize the "User" in my jdl schema as the User used for authentication or will there be a conflict ?


Solution

  • Here's how I've done it in one of my JDL's for a blog app.

    relationship ManyToOne {
      Blog{user(login)} to User
      Post{blog(name)} to Blog
    }
    
    relationship ManyToMany {
      Post{tag(name)} to Tag{entry}
    }
    

    In your case, I think you'll need to do:

    relationship OneToOne {
        StudentInfo{user(login)} to User
    }
    

    login is the field that will show up in the dropdown. Yes, it will recognize the "User" in your JDL schema. Note that this only works with monoliths and microservices with OAuth. It's not supported if you use microservices with JWT or UAA.