JPA2 - JPQL generation problem - An identification variable must not have the same name

607 views
Skip to first unread message

ggran...@gmail.com

unread,
Jun 4, 2015, 11:42:38 AM6/4/15
to minute...@googlegroups.com
Firstly, kudos to the code generation team.  Great tool.  A real time and sanity saver.

I'm getting this error when I add the generated code from any of the JPA2 code generations.

Heres the text of the error for those searching...

"An identification variable must not have the same name as any entity in the same persistence"

If I change the name in @Entity or the identifiers in the JPQL the error goes away.

Is this a code generation problem or is there some configuration I'm missing?

I'm using Eclipse Luna.

Also, unrelated, the names of the classes generated are modified from the table name (camel-casing not respected).  I.e. DrillFolder table becomes class Drillfolder.   Is there a reason for that?  If not, can the camel-case be respected?  Longer table names lose their clarity.

Regards,
-Greg

Florian Adler

unread,
Jun 4, 2015, 4:48:16 PM6/4/15
to minute...@googlegroups.com
Hi Greg,

Thank you for reporting.

1) JPA2 query name: in this case 'drill' is an alias that eclipse report as an error, it is a IDEA error, not compile time error.

2) camel case:
By default Minuteproject convert tables/views with '_' that serves by default as a delimiter for the capital case.
Meanwhile some db use not only block letters and underscore for table name, in this case you need to add two conventions to override the default behavior.

<enrichment>

<conventions>

    <entity-naming-convention type="apply-field-alias-based-on-camelcase"/>

    <column-naming-convention type="apply-field-alias-based-on-camelcase"/>

</conventions>

</enrichment>

You can get some inspiration of the northwind reverse engineering at http://minuteproject.blogspot.be/2013/08/northwind-db-revisited-with-mp-4-ox.html

Best regards,


Florian


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "minuteproject".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse minuteprojec...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Greg Granato

unread,
Jun 4, 2015, 5:32:26 PM6/4/15
to minute...@googlegroups.com
Hey Florian.  

Thanks for the reply.  Can you please clarify what you mean by "it is a IDEA error, not compile time error" ?   The text that is highlighted in the error is in a text string so of course it won't be a 'compile' error.  What I believe its saying is that, at runtime, that SQL statement (JPQL statement) will not run.  I can test it but clearly the spec states the same thing that the error message is asserting.  Are you saying that these JPQL statements will work (I'm using hibernate) and that I just need to ignore the errors (turn off validation seems my only option).



--
Vous recevez ce message, car vous êtes abonné à un sujet dans le groupe Google Groupes "minuteproject".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/minuteproject/HHGvntwa5Rs/unsubscribe.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse minuteprojec...@googlegroups.com.

Florian Adler

unread,
Jun 5, 2015, 4:31:42 AM6/5/15
to minute...@googlegroups.com
Hi Greg,

I've created a unit test on a JPA2 class call Action.

Although the IDEA (here intellij, is reporting some warning/error), the unit calling the name query is issuing a correct sql statement and does not provide runtime error.
Remark: not the the error is not the same as with eclipse...
Is it because Hibernate is used underneath instead of the RI? I do not know.

Inline images 1
Inline images 2


For my point of view the alias can be (should be) any name unique (among the alias).
There are some examples at:

ggran...@gmail.com

unread,
Jun 5, 2015, 6:49:12 PM6/5/15
to minute...@googlegroups.com
Hmmm, that interesting.  I'm not sure your test is conclusive though.  The spec is here:


and it clearly states this:

This is the error that is reported in Eclipse.  I'm wondering if there some special case (db vendor, etc) where those names collide.  In any event, wouldn't it be easy enough for the code gen to simply avoid that?  I'll try to similar tests in my environment soon. 

Regards and Thanks,
-Greg

Florian Adler

unread,
Jun 8, 2015, 4:21:00 AM6/8/15
to minute...@googlegroups.com
Hi Greg,

Fine, I will make the adaptation for the next release, default alias will be 'a', in the event of entity name is 'A' , it will be 'b'.

Best regards,

Florian.

--
Reply all
Reply to author
Forward
0 new messages