Using JDL to Create Blog Demo

1,101 views
Skip to first unread message

Matt Raible

unread,
Apr 5, 2016, 12:51:01 PM4/5/16
to JHipster dev team
Hey guys,

I've started looking into using JDL and JDL Studio to create my blog demo. Here's the JDL I'm trying to use:

entity Blog {
name String required,
    handle String required
}

entity Entry {
title String required,
    content Clob required,
    date ZonedDateTime
}

entity Tag {
name String required
}

relationship OneToMany {
  User{login} to Blog
}

relationship OneToMany {
  Blog{name} to Entry
}

relationship ManyToMany {
  Tag{name} to Entry
}

paginate Entry, Tag with infinite-scroll

When I try to import it, I get the error below. Does anyone know what I'm doing wrong?

Thanks,

Matt

$ yo jhipster:import-jdl ~/Downloads/jhipster-jdl.jh
The jdl is being imported.
Only bidirectionality is supported for a One-to-Many association. The other side will be automatically added.
Error
    at Object.<anonymous> (/Users/mraible/blog/node_modules/jhipster-uml/lib/exceptions/association_exception.js:7:34)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417: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> (/Users/mraible/blog/node_modules/jhipster-uml/lib/helpers/association_helper.js:5:28)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

Mathieu Abou-Aichi

unread,
Apr 5, 2016, 1:00:54 PM4/5/16
to Matt Raible, JHipster dev team
Hi Matt,

I'll look into it tonight, but the subgen uses an old version of everything from JUML. What if you try the example with JHipster UML?
--
Mathieu ABOU-AICHI

Matt Raible

unread,
Apr 5, 2016, 1:41:09 PM4/5/16
to Mathieu Abou-Aichi, JHipster dev team
If I remove the last relationship, the import works. I also had to change "Clob" to "Blob". I tried changing the last relationship to the following:

relationship ManyToMany {
  Entry to Tag{name}
}

But I still get the same error.

I tried looking at the examples and using the following instead.

relationship ManyToMany {
  Entry{tag} to Tag{entry}
}

This seemed to work, but when I started the app, I got the following error:

Caused by: org.h2.jdbc.JdbcSQLException: Table "TAG" not found; SQL statement:
ALTER TABLE PUBLIC.entry_tag ADD CONSTRAINT fk_entry_tag_entry_id FOREIGN KEY (tags_id) REFERENCES PUBLIC.tag (id) [42102-191]

I figured this might be because I have "entity Entry" before "entity Tag" and I remember having to generate Tag before Entry when using the entity sub-generator. So I started with a clean project and tried again. This time, startup worked. 

However, it looks like something might be broken with bower because I don't have any Bootstrap CSS or AngularJS in my index.html.

The normally populated vendor files are blank.

    <!-- build:css content/css/vendor.css -->
    <!-- bower:css -->
    <!-- endbower -->
    <!-- endbuild -->

<!-- build:js app/vendor.js -->
<!-- bower:js -->
<!-- endbower -->
<!-- endbuild -->

After some investigation, it seems that running "./gradlew" on its own isn't enough to get the files injected into index.html. When I ran "gulp", it injected them. Is this a bug? It seems like you should be able to just run "./gradlew" after creating a new project and have it all working. At least that's the way it used to work.

[BS] Serving files from: src/main/webapp/
[11:37:28] gulp-inject 118 files into index.html.
[11:37:28] Finished 'inject' after 324 ms

Thanks,

Matt

Matt Raible

unread,
Apr 5, 2016, 2:02:26 PM4/5/16
to JHipster dev team
With the entity sub-generator, I’m able to generate a Clob text field. It looks like JDL doesn’t support this. Is that correct? When I generate it with the sub-generator, here’s what my .jhipster/Foo.json looks like:

{
    "relationships": [],
    "fields": [
        {
            "fieldName": "content",
            "fieldType": "byte[]",
            "fieldTypeBlobContent": "text"
        }
    ],
    "changelogDate": "20160405175720",
    "dto": "no",
    "service": "no",
    "entityTableName": "foo",
    "pagination": "no"
}

Finally, below is the JDL that seems to work to reproduce a blog demo.

Cheers,

Matt

----
entity Blog {
name String required min(3),
    handle String required min(2)
}

entity Tag {
name String required min(2)
}

entity Entry {
title String required,
    content String required,
    date ZonedDateTime
}

relationship ManyToOne {
  Blog{user(login)} to User
}

relationship ManyToOne {
Entry{blog(name)} to Blog
}

relationship ManyToMany {
  Entry{tag(name)} to Tag{entry}
}

paginate Entry, Tag with infinite-scroll
----

deepu ks

unread,
Apr 5, 2016, 8:30:00 PM4/5/16
to Matt Raible, JHipster dev team
Hi Matt,

the import JDL uses an older version of JHUML which doesnt work with defining a one sided relationship. Also current release still has the relationship dependency constraint (but current master doesnt have it, means you can create entity in any order now)

Regarding the vendor file issue, ill investigate it. seems like a regression.
Yes seems like clob is not supported yet 

below is the JDL I used for my demo


entity Blog {
  name String required minlength(3),
  handle String required
}

entity Tag {
  name String required
}

entity Entry {
  title String required,
  content String required,
  date ZonedDateTime required
}

relationship ManyToOne {
  Blog{user(login)} to User
}

relationship OneToMany {
  Blog{entry} to Entry{blog(name)}
}

relationship ManyToMany {
  Entry{tag(name)} to Tag{entry}
}

paginate Tag, Entry with pagination

dto all with mapstruct

service all with serviceImpl


Thanks & Regards,
Deepu

--
You received this message because you are subscribed to the Google Groups "JHipster dev team" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jhipster-dev...@googlegroups.com.
To post to this group, send email to jhipst...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jhipster-dev/6873F9DB-ABB7-4F37-ABDC-C29A43D2DC2D%40raibledesigns.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages