- This topic has 52 replies, 3 voices, and was last updated 4 years, 11 months ago by Brian Fernandes.
-
AuthorPosts
-
MorkParticipantI created another entirely new workspace and this time JPA reverse engineering worked from the MyE perspective.
Thus, there seems to be something off or corrupted with the existing workspace? That’s odd since the other projects in that workspace are OK. The MyEclipse CI workspace is within other workspace folders from previous versions so maybe there’s some confusion there?
We need a way to debug this problem and I’m surprised there’s no way to do that from MyEclipse to track down these (now > 3 weeks) problems. In the meantime, I’ll work around this by creating extra workspace folders I don’t want or need.
Will keep you updated.
MorkParticipantHaving an issue with JPA.
Here’s my test main class (testing prior to re-creating the JAX_WS service):
public class RunJpa { public static void main(String[] args) { ZipcodesId zipId = new ZipcodesId(); zipId.setZipcode(90210); ZipcodesDAO dao = new ZipcodesDAO(); System.out.println(dao.findById(zipId)); System.out.println(dao.findByProperty("zipcode", 92010)); }
Neither of these work.
In the first System.out.println above, I get: null
In the second one, I get:
Caused by: org.hibernate.QueryException: could not resolve property: zipcode of: com.ht.jpa.Zipcodes
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:62)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:56)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1788)
at org.hibernate.hql.internal.ast.tree.FromElementType.getPropertyType(FromElementType.java:393)
at org.hibernate.hql.internal.ast.tree.FromElement.getPropertyType(FromElement.java:505)
at org.hibernate.hql.internal.ast.tree.DotNode.getDataType(DotNode.java:660)
at org.hibernate.hql.internal.ast.tree.DotNode.prepareLhs(DotNode.java:264)
at org.hibernate.hql.internal.ast.tree.DotNode.resolve(DotNode.java:204)
at org.hibernate.hql.internal.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:109)
at org.hibernate.hql.internal.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:104)
at org.hibernate.hql.internal.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:1013)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1286)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4713)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4183)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2130)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:813)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:607)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:311)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:259)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190)
… 10 more—-
The generated classes are two long to post so I’m adding them as a zip file.
Can you explain what I need to do to make this work again? Could not resolve using your online example/
I can do a SQL statement that brings back the record with all the data.
Thanks in advance,
Attachments:
You must be logged in to view attached files.
Brian FernandesModeratorMork,
It’s good to know you were finally able to get things going, somewhat. Can you clarify if reverse engineering from the project context works or do you still have to initiate from the DB Browser?
I can’t see a reason why the workspace itself would result in a difference, certainly nested workspaces aren’t a problem. There are other differences that could come from the new workspace which could explain the fact that its now working, like a different Java version, and a freshly created Database connector, and, changes that come from a new project. Not sure which of these would really be applicable in your case, just mentioning a few of the things that could change with new workspaces. Have you tried importing your older project from the older workspace into the newer one and seeing if it works there?
As far as debugging the problem – no, we don’t have logging statements everywhere in the code that we can just turn on. We do have a few, which is what has given us the logs already pointing to the error. We can definitely generate a new version of the plugin with advanced logging as required – having all that in the code, everywhere, isn’t efficient.
Coming to the actual error when running the application, what console output are you seeing when you run the program, is nothing showing before the first print statement? IIRC there would be some messages from the initialization of the persistence provider and its connection to the database. Would it be possible to share the entire project so we see all the other metadata as well?
Thanks!
MorkParticipantHi Brian,
Sent you the project via email to your attention.
It’s only about 2.1 MB but if that’s too big for your email filter and you don’t receive it, please let me know and I’ll put it on DropBox or something.
Thanks,
MorkParticipantDid you get my Project zip file in the email I sent you that you requested?
Haven’t heard back from you yet so just following up.
Thanks,
Brian FernandesModeratorMork,
I just found the email with the project, thanks. With a quick glance, everything appears to be fine, including your persistence.xml file. I will be running a more detailed test on it tomorrow and will keep you posted.
Brian FernandesModeratorMork,
I didn’t catch this yesterday when looking at persistence.xml but I think one problem is the fact that you’re using Hibernate specific properties in a JPA project. These properties can still be used, but should be for configurations that are specific to Hibernate. You didn’t answer my question on whether you are seeing JPA initialization output before your project code runs, so not sure if you’re affected by this – would still be important to know the answer to this.
1) Here’s what you can change your hibernate properties to:
<properties> <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" /> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/ZipCodeLookup?autoReconnect=true&useSSL=false&serverTimezone=America/New_York" /> <property name="javax.persistence.jdbc.user" value="zipcodeuser" /> <property name="javax.persistence.jdbc.password" value="zipzip" /> </properties>
2) I think another problem may be the fact that the Zip code table has no primary keys defined in the Database itself. What this is resulting in, therefore, is classes that are taking all columns together as part of the primary key (I got the same on generation with your schema). Even if you got this working previously, there’s no way this really makes sense, nor is this efficient, so you should consider modifying your table to make the
ZipCode
column the primary key, as that will be unique across all entries, and then reverse engineer again.Hope this helps!
MorkParticipantI repeated the bug find. Now, generate JPA does NOT work again!
First of all…. Actually, zip code is not unique at all. It would be repeated for many counties.
There is a RecordNumber field so I just made that the key. (this step was not required when MyEclipse worked as expected previously)
HOWEVER … when deleting the project and the directory contents and (again…) starting over, again NOTHING HAPPENS when I clicked the OK button on the reverse engineering button in the project!!!
This is ridiculous.
See if you can create a working project. Then, delete it (using MySQL 8 and the my version of the JDBC driver). See if you can start over and reverse engineer.
I’m really unhappy with your product at this moment.
I need to struggle with Intellij to get this project working since I’m now almost a month late trying to get MyEclipse to work correctly.
Brian FernandesModeratorFirst of all…. Actually, zip code is not unique at all. It would be repeated for many counties.
There is a RecordNumber field so I just made that the key. (this step was not required when MyEclipse worked as expected previously)
I hadn’t seen the data, so had no idea; glad you found the right Primary Key.
Let me be clear on a few aspects:
1) MyEclipse code generation for reverse engineering has not changed, because it hasn’t needed to. It is still generating the same code it did for the last five years, perhaps even longer. So what you are getting now, I’m reasonably sure, is the same as the code you had before. I can’t be 100% sure, because you can’t tell me what version of MyEclipse you last used.2) There’s more to JPA than just reverse engineering, and ME has generated the code for you. You still need to set up your persistence.xml correctly, have the right libraries in the project, etc. MyEclipse never did this automatically, this is up to you, as a JPA developer. If this worked in the past, either you took additional steps, or steps that were different from what you are taking right now.
3) My suggestion on adding a Primary Key is based on very basic DB/persistence fundamentals for correctness and efficiency. It’s quite possible that your last project worked without them, and this is not the reason for your current failure, but I would like to think you’d appreciate a project that runs well/correctly.
4) I’m serious disappointed that our original elusive problem has surfaced again. I have asked you several questions in my previous responses which could help us narrow down why it worked with the new workspace (if only for a bit) but have received no replies. Here they are again.
When it did work in the new workspace:
a) Can you clarify if reverse engineering from the project context works or do you still have to initiate from the DB Browser?
b) Have you tried importing your older project from the older workspace into the newer one and seeing if it works there?
c) For the error you see when running the application, I asked twice if you see the persistence provider initializing (with output in the console) before your application runs. Just seeing your project output immediately would indicate that the PP is not running or engaged.Some additional thoughts:
d) We’ve tried this across a dozen workspaces, and yes, I specially tried deleting the project and regenerating right now – works fine. I reiterate, not saying that you aren’t running into a bug, just that we cannot reproduce it. Deleting and regenerating is not the key step to reproduction, unfortunately.
e) It should not matter, but I’m not sure why you are deleting the project instead of just generating again, or deleting generated classes. You wouldn’t need to set up persistence.xml again for instance.
f) You have a project that works fine, generated with a previous version of MyEclipse. Has this project been completely lost? You said earlier that you deleted it, but perhaps I’ve misunderstood why you would delete a working project which is not checked into a VCS. What am I missing here?
MorkParticipantOk … I got it working from the database browser only (still nothing happens from the project side) using your online tutorial example exactly. Specifically, I did not try to use Hibernate. I think using Hibernate where the issue was for some of this. I also created an “ID” field in the database — renamed the “RecordNumber” field to “ID” and made it primary.
The reason I deleted the whole project/workspace/etc was to try to get MyEclipse to do something after I clicked “OK” to generate DAOs from the project view. That deletion didn’t help. I was also trying to make sure I just didn’t miss something.
I still have the built project from before that works online. However, the source code for that project was no longer working in the existing workspace I had which is when I started this thread.
—-
After being with MyEclipse for over a dozen years, I took a hiatus and used Intellij. Yet IMHO Intellij leaves too much grunt work to the developer other than it’s superb editor. I came back to MyEclipse last year so the version must be in that range.
I’ll try to get the JAX_WS service back up tomorrow.
Thanks for all your help and patience. This has been very frustrating for all of us I’m sure. 🙂
- This reply was modified 4 years, 11 months ago by Mork.
-
AuthorPosts