I have calmed down and wish to apologize for the harshness of my comments last 
night. I will download the latest source and review the code that generates the 
controllers et all. I will suggest that there should be two choices for JPA 
Controllers, one for stand alone and one for application server managed.

Ken

________________________________
From: Kenneth Fogel <kfo...@dawsoncollege.qc.ca>
Sent: Friday, February 14, 2020 12:51:59 AM
To: dev@netbeans.apache.org <dev@netbeans.apache.org>
Subject: JPA Controller Generation

I have been using NetBeans, as many of you know, for years. In the winter I 
teach an EE course that uses the JPA. In using the New -> JPA Controllers from 
Entities I couldn’t believe what came out. Let’s review two changes:

If the persistence.xml file does not declare a connection (url, user, pwd) the 
generated controllers are empty. When this file is used for EE JPA you declare 
the connection in glassfish-resources.xml and not the persistence.xml. Previous 
versions of NB did show the connection details but if I edited for EE JPA and 
then generated the controllers they were still generated. The controllers are 
generated from the entities so why is the generator even looking at 
persistence.xml.

Then there are the controllers themselves. They have been optimized for stand 
alone, resource local usage. The optimizations, especially the use of finally 
clauses to eliminate catch clauses makes no sense to me. Many but not all 
exceptions simply result in an em.close(). This is effectively the same as 
having an empty catch clause. Plus, with an injected  EntityManager you should 
not be closing it, if I understand how CDI works. There is no rollback 
anywhere. If the JPA now rolls back automatically when an exception occurs I’ll 
withdraw this complaint but I doubt it does.

I could go on. If you want to see what controllers used to look like and what 
had to be changed for EE look at my blog https://www.omniprogrammer.com/?p=383.

Is the JPA used more extensively on the desktop? I don’t think so. Here I take 
the blame for not pointing out that there needs to be JPA generation for 
Application Servers. If you look at my blog you can see that the changes were 
minimal to the old generated code. Now the changes will need to be more 
extensive.

I have to stop now because I’m angry. Tomorrow morning I have to face a class 
and before that I need to decide if I should tell them to cut and paste code 
from my samples and change the names of objects or show them all the changes 
needed to make the generated code work.

Please tell me I have it all wrong and I’ll be happy to apologize for this 
missive and never darken this mailing list again. I will also be happy to 
contribute JPA/EE controller templates if my concerns are valid.

Ken





Reply via email to