Community
Participate
Working Groups
Build Identifier: I-3.4.0-20111117042436 1. Bring up the entity gen wizard, select a couple of tables and go to the Table Associations page 2. Click New Association button to bring up the Create New Association page 3. Select 'Many to many association' radio button and configure the association tables properly 4. Complete the rest steps and click Finish Check the generated entities and you'll see the join strategy for the customized ManyToMany association is JoinColumn instead of configured JoinTable and the properties set to the join table are lost. Reproducible: Always
Dynamic entity gen wizard has the same issue. With customized many-to-many association the corresponding generated XML piece likes: <many-to-many name="projects" target-entity="model.Project" attribute-type="java.util.List"> <join-column name="PROJ_ID"/> </many-to-many> Thinking that's because both wizard uses the same code base.
JoinTable strategy is applied if join table set at step 3 is one of the tables chosen at step 1; otherwise, JoinColumn strategy is applied.
Created attachment 218602 [details] Proposed Patch
(In reply to comment #2) > JoinTable strategy is applied if join table set at step 3 is one of the tables > chosen at step 1; otherwise, JoinColumn strategy is applied. I think this is actually the expectation of how the wizard is supposed to work. If you were to not select a join table that was used in a inferred association, the M-M association wouldn't be created either. I guess the question is whether we should change this "as designed" behavior for the case where an association is being added and the desired join table hasn't already been selected by the user. Since the table is not selected in the initial wizard page, generally speaking, this table would be seen as being out of context to the following operations. Perhaps this decision should be revisited though.
I got what you mean and I overlooked one thing that no entity is generated for the table chosen as the join table. I thought entities would be generated for all the chosen tables. But M-M does not support JoinColumn strategy. Was it ever supported, e.g. with JPA 1.0? Anyway, I agree that we need to rethink how things should work along with a change I made previously to let use choose join table from the list of table in the database instead of the list of chosen tables.
Yeah...Many to Many shouldn't be defining a JoinColumn strategy. The generator isn't handling this error case very well.
I think we should just defer this enhancement for now, given that the scope of the work to address it has gotten too large. We have bigger issues to deal with, and we haven't had any external bugs reported in this area. We can also roll back the fix for the other bug that you mentioned in comment 5.
Created attachment 220904 [details] additional patch This patch is for rolling back previous fix for handling join table. Users will still select join table from the list of selected tables instead of the list of available tables in the database.
This patch is based on the following commit: 2895790 removed now unnecessary validation methods Karen Butzke
Just to make this a little less confusing, we should probably attach the additional patch on the related bug 362203 instead of this one for better tracking.
I thought to put the additional patch to bug 362203, but the fix for bug 362203 is only partially related to the changes in the new patch and not all the changes of it were rolled back. I was thinking it would be easier to find all the related parties that need to be changed while fixing this bug so I attached the patch with this bug. I can also attach the new patch to bug 362203 and list the related bugs here if you prefer. If so, I assume that I am suppose to reopen bug 362203.
(In reply to comment #11) OK...that sounds fine. We can just make a comment in bug 362203 that mentions this. I can commit the additional patch and we can leave this bug open for the future.
The following bugs should be taken into consideration when fixing this bug: bug 362203 bug 364197 The decision made for this bug could affect the fix for the bugs above.
Comment on attachment 220904 [details] additional patch We don't need this additional patch to roll back changes since no changes need to be rolled back.
One more bug to consider when fixing this bug: bug 364201 Currently, entity gen wizard gives all the available tables in the database for join table, which means user can choose any table as the join table; however, it seems everything works properly only when the join table is one of the previous selected tables.