Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 195832

Summary: [Entity Gen] Add option to refresh DB metadata prior to entity generation
Product: [WebTools] Dali JPA Tools Reporter: Michael OBrien <michael.f.obrien>
Component: JPAAssignee: Tran Le <tranle1>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jolene.moffitt, neil.hauge, shaun.smith, stefan.dimov
Version: 1.0Keywords: plan
Target Milestone: 3.1 M1   
Hardware: PC   
OS: Windows XP   
URL: http://wiki.eclipse.org/Dali_3.1_M1
Whiteboard: EaseOfUse

Description Michael OBrien CLA 2007-07-09 10:34:39 EDT
Dali is caching schemas in eclipse betweeen table drop/recreates. The class should be cleared between entity generation commands.

A drop/recreate of the tables and a regeneration of entities (with/without deletion of existing entities) will not update files until we refresh the db connection in the [database explorer view] or exit/reenter eclipse.

Reproduction:
1 - Create some DB tables using sql scratchpad
2 - generate entities in dali
3 - alter tables by adding foreign key constraints or drop/recreate tables (with column changes)
4 - java enties will not be updated

3b - add a refresh to the connection/db/schema/tables in the [database explorer] window - to fix this problem.

Platform:
Eclipse 3.2.2 or 1.5.3
Windows XPSP2
Comment 1 Neil Hauge CLA 2007-07-12 16:35:23 EDT
We can look into whether or not it is possible to refresh the tables from outside the DTP UI.  I assume it is.  The other question is whether we want this (refresh) to remain a user driven action as it is now.  It is probably OK to refresh when generating, since I'm not sure why the the user would want their DB view to be stale, especially when generating Entities.
Comment 2 Neil Hauge CLA 2008-05-23 11:50:01 EDT
Didn't have time to get this into 2.0, deferring to next release.
Comment 3 Neil Hauge CLA 2008-11-17 11:17:41 EST
After discussing this with Shaun, we decided that this is more of an issue with DTP not updating the DB model when changes are made through their UI.  This could be filed as a separate bug against the Data Tools project.

As a workaround, we could add an "Update Tables Before Generating" (or something to that effect) option to the Entity Generation wizard, which would ensure that generated entities were never created with stale DB metadata.  This would be a checkbox option, in the case that updating from the DB was a very time consuming activity, and the user knew that the tables were already up-to-date.
Comment 4 Neil Hauge CLA 2011-07-01 16:25:53 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 5 Stefan Dimov CLA 2011-07-15 11:16:21 EDT
We (SAP) have internal ticket about this. It's not quite the same, because the user requests refreshing of the content of the generate entities wizard (GenerateEntitiesFromSchemaWizard), but I guess the root is the same. I mean - if data source explorer refreshes (automatically or manually) then also the content of the wizard will be refreshed. Although, if the refreshing is manual, perhaps an additional refresh button should be added to the wizard as well as to the data source explorer.
Comment 6 Neil Hauge CLA 2011-07-15 12:01:57 EDT
Given the current Entity Gen wizard, a button on the first page of the wizard probably makes the most sense.  This button could be labeled, "Refresh Tables".  Clicking this button would call for a refresh of the DTP model and would subsequently update the Tables list on the first page of the wizard.

We will look at implementing this for the next release.
Comment 7 Neil Hauge CLA 2011-07-26 17:40:19 EDT
Here is the location of a refresh icon from the platform that we should be able to use for this button.

eclipse\plugins\org.eclipse.ui.browser_3.3.100.v20110426.jar\icons\elcl16\
Comment 8 Tran Le CLA 2011-08-02 15:53:46 EDT
Added the API in the JPT DB plugin to perform a "refresh". And also added a "Refresh Tables" button to the first page of the Entity Gen wizard.

Implemented in 3.1M1
Comment 9 Jolene Moffitt CLA 2011-09-15 14:08:08 EDT
Verified in Build I-3.4.0-20110912100409 

Verified refresh button was added to Generate Entities from Tables. See the link to view test steps for verification. http://wiki.eclipse.org/Dali_3.1_M1
Comment 10 Michael OBrien CLA 2011-09-15 14:28:00 EDT
>Jolene, thank you for resolving this issue - appreciated