Skip to content
This repository has been archived by the owner on Oct 28, 2019. It is now read-only.

Fix the UndeclaredEntityException message when not providing a relationship name #172

Closed
lsgpimentel opened this issue Mar 24, 2016 · 13 comments
Milestone

Comments

@lsgpimentel
Copy link

The issue

Look at the A_blabla_to_B_null part in the stacktrace.

Better to remove the _ as separator too and use brackets.


The stacktrace

An error has occurred:
    UndeclaredEntityException
Error message:
    In the association A_blabla_to_B_null, the entity A is not declared.
Stack trace:
Error
    at Object.<anonymous> (/usr/lib/node_modules/jhipster-uml/lib/exceptions/undeclared_entity_exception.js:7:39)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/lib/node_modules/jhipster-uml/lib/dsl/dsl_parser.js:12:33)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)



The XMI or JDL file

relationship ManyToMany {
  A{blabla} to B
}

Versions

JHipster JHipster UML
2.27.2 1.6.4
@MathieuAA
Copy link
Member

Hello, you actually have to declare A entity A and B entity B.

@lsgpimentel
Copy link
Author

@MathieuAA,

I know that. This was intentional.

Like I said, look at the message: "In the association A_blabla_to_B_null, the entity A is not declared."

@MathieuAA
Copy link
Member

Oh, sorry then!

I'll have a look in a few minutes.

@MathieuAA
Copy link
Member

I don't think you use v1.6.4 of JHipster-UML... this message was replaced by: In the Many-to-Many relationship from A to B, only bidirectionality is supported for a Many-to-Many relationship..
You might still be stuck to v1.6.2...

Now for the error, I suggest you read the "Managing Relationships" page in the doc. I'll keep this thread open if you want help getting the last version, I know this can be very painful!

@lsgpimentel
Copy link
Author

 $ jhipster-uml -v
The current version of JHipster UML is 1.6.4.

Please look at https://github.com/jhipster/jhipster-uml/blob/master/lib/dsl/dsl_parser.js#L233

@MathieuAA
Copy link
Member

Too tired to see the real problem, sorry.
There is no problem at all.
It's working as intended.

The stacktrace was made so that we analyze it, even the ID is working for us here.

@MathieuAA
Copy link
Member

Took me a real long time to understand what you wanted... now for the really long explanation: you don't have IDs in the JDL because we don't need to identify objects in the JDL file. However, we need them to access objects later in the generation process.
In any XMI file, IDs are absolutely mandatory because of the XMI file creation process (a real mess I guess).

If a user has an error, this message will tell us the nature of the relationship and how it was created. That's completely normal.

Again, sorry to have taken such a long time to correctly understand you.

@lsgpimentel
Copy link
Author

Hehehe... Maybe I'm being too laconic, sorry.

jhipster-uml is correct when it throws the UndeclaredEntityException. What bothers me is the message when you don't provide the relationship name. You should test to see if the relationship name is not declared and put empty instead of null.

It's stupid, I know...

Take a look at https://github.com/jhipster/jhipster-uml/blob/master/lib/dsl/dsl_parser.js#L49

@MathieuAA MathieuAA added this to the 1.6.5 milestone Mar 26, 2016
@MathieuAA
Copy link
Member

You're not. But it's actually really difficult for people to understand one another when not communicating face to face.

I'll see what I can do about it sometime after at least ten hours of sleep and a nice cup of tea.
I'll release the enhancement before tomorrow I hope.

@MathieuAA
Copy link
Member

The new error message: In the relationship between A and B, the entity A is not declared.

@lsgpimentel
Copy link
Author

@MathieuAA,

The message just below should not be changed too?
https://github.com/jhipster/jhipster-uml/blob/master/lib/dsl/dsl_parser.js#L249

@MathieuAA
Copy link
Member

Oh. I didn't see it at all. Thanks!

MathieuAA pushed a commit that referenced this issue Mar 27, 2016
@MathieuAA
Copy link
Member

Merged the checks/throws into one:

  var absentEntities = [];

  if (!this.parsedData.getClass(association.from.name)) {
    absentEntities.push(association.from.name);
  }
  if (!this.parsedData.getClass(association.to.name)) {
    absentEntities.push(association.to.name);
  }
  if (absentEntities.length !== 0) {
    throw new UndeclaredEntityException(
        'In the relationship between '
        + association.from.name
        + ' and '
        + association.to.name
        + ', '
        + absentEntities.join(' and ')
        + (absentEntities.length === 1 ? ' is' : ' are')
        + ' not declared.'
    );
  }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants