This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 73769 - Relationship names for beans generated from database are incorrect
Summary: Relationship names for beans generated from database are incorrect
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: EJB (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
: 75757 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-20 16:31 UTC by Jan Horvath
Modified: 2006-07-12 19:58 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Horvath 2006-03-20 16:31:08 UTC
build 200603200300

-open/create EJB module 
-create beans from sample db
-ERROR generated relationships has wrong names (e.g. "null-1")
Comment 1 Jan Horvath 2006-03-20 16:32:17 UTC
of course this is for J2EE 1.4 version of EJB module
Comment 2 Andrei Badea 2006-07-11 13:20:15 UTC
Fixed hopefully. Pavel or Rochelle, could you please review? Thanks.

Checking in
src/org/netbeans/modules/j2ee/persistence/entitygenerator/DbSchemaEjbGenerator.java;
/cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/entitygenerator/Attic/DbSchemaEjbGenerator.java,v
 <-- DbSchemaEjbGenerator.java
new revision: 1.1.2.1.2.10; previous revision: 1.1.2.1.2.9
done
Comment 3 Rochelle Raccah 2006-07-12 00:29:10 UTC
*** Issue 75757 has been marked as a duplicate of this issue. ***
Comment 4 Rochelle Raccah 2006-07-12 00:33:01 UTC
Andrei - behavior looks okay.  My only concern is the difference b/w this code
and the other setRelationName call in the method makeRelationsUnique.  Should
that code be factored?
Comment 5 Andrei Badea 2006-07-12 08:39:02 UTC
It seems to me the difference is there because the calls do something different.
The setRelationName() call I added sets the name of a 1:N relationship (there is
yet another call in addJoinTable() setting the name of a N:M relationship). But
the call in makeRelationsUnique() has a different meaning - it just adds numbers
to duplicate names in order to ensure unique names.

So I don't see a need to refactor. Unless I'm missing something, of course.
Comment 6 Rochelle Raccah 2006-07-12 18:57:40 UTC
Yes, I agree they are probably different.  My 2 thoughts were:
1) Is it possible that this one might also need a uniquing check in some strange
case?
2) The use of "-" with the 2 names - if we foresee changing this in any way (or
doing something special for i18n) then we would need to do it in 2 places
instead of just one.
Comment 7 Andrei Badea 2006-07-12 19:22:59 UTC
Re. 1: the uniquing check is done at the end of buildMPSet(), it doesn't seem to
need to be done explicitly. 

Re. 2: This doesn't sound likely, and moreover, the '-' in the code I added
could be even regarded as different from the '-' in makeRelationsUnique(). For
the uniquing algorithm we can decide to use something else and still use the
dash as the entity name separator, like in "PersonBean-AddressBean#1" (OK, I
don't know if # would be a valid char in this context).

Feel free to reopen if you disagree, I can introduce a field for the '-' and use
it in both methods. Or perhaps if you have an idea how to refactor the code
please describe it here and I can implement it (unless you want to, of course :-)
Comment 8 Rochelle Raccah 2006-07-12 19:58:08 UTC
No need to reopen, just wanted to bring up those points.