Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jakarta EE Entitiy and EJB support #6129

Merged

Conversation

asbachb
Copy link
Collaborator

@asbachb asbachb commented Jun 27, 2023

Added ability for Jakarta EE projects to:

  • Create entities from database tables
  • Create message driven, stateful, stateless and session beans

This should fix #4827 #4828

@matthiasblaesing matthiasblaesing added the enterprise [ci] enable enterprise job label Jun 27, 2023
@matthiasblaesing matthiasblaesing added this to the NB19 milestone Jun 27, 2023
@apache apache locked and limited conversation to collaborators Jun 27, 2023
@apache apache unlocked this conversation Jun 27, 2023
Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the license check fails because the new templates have no license header. In that modules the templates are assigned a license using the licenseinfo.xml file in the root of the module. Please add the new templates to the list.
I left two further comments inline.

@asbachb asbachb force-pushed the jakarta-namespace-entity-sessionbeans branch from 2036ca5 to 5fdf9ab Compare June 28, 2023 08:33
@asbachb
Copy link
Collaborator Author

asbachb commented Jun 28, 2023

Added files to licenseinfo.xml.

@mbien mbien added the Java EE/Jakarta EE [ci] enable enterprise job label Jun 28, 2023
@matthiasblaesing matthiasblaesing added the ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) label Jun 28, 2023
@apache apache locked and limited conversation to collaborators Jun 28, 2023
@apache apache unlocked this conversation Jun 28, 2023
@matthiasblaesing
Copy link
Contributor

If noone objects, I'll merge on the weekend. @juneau001 you might want to have a look.

Copy link
Contributor

@juneau001 juneau001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested this PR and the entity classes do generate. However, when I generate on a Jakarta EE 9 or Jakarta EE 10 project, the classes generated with javax.* imports. I tested on existing projects...not new projects. Thanks for the work on this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to support Jakarta EE 9+? I am testing on a Jakarta EE 10 project and javax.* entities are being generated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to support Jakarta EE 9+? I am testing on a Jakarta EE 10 project and javax.* entities are being generated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% if this needs to be adjusted at all for Jakarta EE 9+...looks great with the new enterprisePrefix, but my entities are still being generated with javax.* on a Jakarta EE 10 project

@asbachb
Copy link
Collaborator Author

asbachb commented Jul 16, 2023

@juneau001 @matthiasblaesing @mbien can we get this back to move somehow? Would be nice to have it in NB19.

I created two maven web applications one with jakarta ee 10 and one with jakarta ee 9 in NetBeans 18 and opened it with the PR. Stateful and stateless session beans were created with the correct imports.
So I'm currently unable to reproduce the mentioned behavior without further details. @juneau001 can you double check?

Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good to me

Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see what @juneau001 saw: The title of this PR contains "Jakarta EE Enttiy", so this implies that I can generate @entity beans. This generates code with wrong package. Steps to reproduce:

Create Java EE 10 Web Project

  • Build this branch, remove nbbuild/testuserdir, run ant tryme
  • Create a new project "Java with Maven" > "Web Application"
  • Fill Name and Location Data (not relevant for this test)
  • Select "Add" for Server and choose "Glassfish", choose a local folder and download 7.0.5
  • Accept domain1 defaults
  • Ensure Java EE version is set to "Jakarta EE 10 Web"
  • Generate project

Prepare JavaDB Connection

  • Go to services tab
  • Select Database -> Drivers -> "Java DB (Network)", Choose "Customize"
  • Add "derbytools.jar" from $glassfishDir/javadb/lib folder

Try to generate entity classes

  • Open Context menu on project node, choose "New" -> "Entity classes from Database"
  • In the "Data Source" dropdown select jdbc/sample
  • Select table "CUSTOMER" and the "Add"
  • Select "Next" until to reach the last page of the wizard, then select "Finish"

=> Now check the generated classes, for example "Customer.java". You'll see, that the javax.persistence classes are used, although we are in an JakartaEE project

@mbien
Copy link
Member

mbien commented Jul 17, 2023

can we merge this and fix the remaining issue during RC1?

my understanding is:

  • this PR causes no known regression
  • it improves the current situation
  • the remaining problem is likely fixable without having to rewrite everything

deadline is today night UTC

@asbachb
Copy link
Collaborator Author

asbachb commented Jul 17, 2023

I fixed the mentioned use case, currently in testing phase.

* Create entities from database tables
* Create message driven, stateful, stateless and session beans

This should fix apache#4827 apache#4828
@asbachb asbachb force-pushed the jakarta-namespace-entity-sessionbeans branch from 5fdf9ab to dabf55f Compare July 17, 2023 13:39
@asbachb asbachb requested a review from matthiasblaesing July 17, 2023 13:40
@asbachb
Copy link
Collaborator Author

asbachb commented Jul 17, 2023

Pushed fixed for that use case. Tested with steps mentioned in #6129 (review)

  • Jakarta EE 10 application
  • Jakarta EE 8 application

@asbachb asbachb requested a review from juneau001 July 17, 2023 14:58
Copy link
Contributor

@juneau001 juneau001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the code and it looks great. I also updated my local code based upon the latest changes and tested today. I am now able to create entity beans from database for a Jakarta EE 9+ project and I receive jakarta.* imports. Likewise, if I do the same for Jakarta EE 8- projects then I receive javax.* imports. Appears to be working well. Thanks for all of your time on this issue!

@matthiasblaesing
Copy link
Contributor

Thanks for the update, I'm doing a local sanity build and if ok, I'll merge.

@matthiasblaesing matthiasblaesing merged commit 0bee9d3 into apache:master Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) enterprise [ci] enable enterprise job Java EE/Jakarta EE [ci] enable enterprise job
Projects
None yet
4 participants