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.
Summary: | Persistence Entity Class From Database Generation - @ManyToOne Issue | ||
---|---|---|---|
Product: | javaee | Reporter: | mpapamichael |
Component: | Persistence | Assignee: | Sergey Petrov <sj-nb> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | pjiricka |
Priority: | P3 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
mpapamichael
2010-04-29 12:17:07 UTC
Name is generated based on referenced column name, not entity name. I need to investigate a bit more but there may be side effects if change this approach to entities names usage. And if there are no problems except strange constructions in code to get id like "abc.abc" if referenced column is "abc" it looks more like enhancement for me. But samples from jpa 2.0 specification use entity name in this case, may look if it can be changed in 6.9 thanks, if it can be changed it will be very helpful. (In reply to comment #2) > But samples from jpa 2.0 specification use entity name in this case, may look > if it can be changed in 6.9 for future reference: org.netbeans.modules.j2ee.persistence.entitygenerator.DbSchemaEjbGenerator::generateRelationship(ForeignKeyElement key) initially generate name based on entity type, but right after first generation have comment " /* only use database column name if a column is not required by the primary key. If a column is already required by the primary key then executing this code would cause the cmr-field name to be named cmp-fieldname1. Therefore, we do not change the cmr-field name and instead use the name of the other ejb (default). */ " and the name is regenerated based on field name. It require additional investigation as it was implemented more then 3 years ago, don't see a reason for special handling in this place, functionality is changed to use ejb name always, change shouldn't have bad side effect in my opinion effects as it was already supposed behavior but only in special cases. http://hg.netbeans.org/web-main/rev/122c9a147dc2 thanks for your response, i will be working using the most recent dev built. if i notice anything else i will let you know. regards michael (In reply to comment #5) > don't see a reason for special handling in this place, functionality is changed > to use ejb name always, change shouldn't have bad side effect in my opinion > effects as it was already supposed behavior but only in special cases. > > http://hg.netbeans.org/web-main/rev/122c9a147dc2 Integrated into 'main-golden', will be available in build *201005100200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/ User: Log: Hi guys i just made changes to my database, i tried to use the new entities update feature. the outcome was i got a lot of duplicates, because i renamed all my foreign key attributes to the entity name(class name), it assumed that those attributes where missing. these are the attributes already there(these i changed to meet my needs). @JoinColumn(name = "ServiceProviderID", referencedColumnName = "ServiceProviderID") @ManyToOne(optional = false, fetch = FetchType.EAGER) private Serviceprovider serviceProvider; @JoinColumn(name = "SimTypeID", referencedColumnName = "SimTypeID") @ManyToOne(optional = false, fetch = FetchType.EAGER) private Simtype simType; these are the newly generated onces, as you can see more or less are the same attributes. @JoinColumn(name = "ServiceProviderID", referencedColumnName = "ServiceProviderID") @ManyToOne(optional = false) private Serviceprovider serviceProviderID; @JoinColumn(name = "SimTypeID", referencedColumnName = "SimTypeID") @ManyToOne(optional = false) private Simtype simTypeID; (In reply to comment #6) > thanks for your response, i will be working using the most recent dev built. if > i notice anything else i will let you know. > > regards > > michael > > (In reply to comment #5) > > don't see a reason for special handling in this place, functionality is changed > > to use ejb name always, change shouldn't have bad side effect in my opinion > > effects as it was already supposed behavior but only in special cases. > > > > http://hg.netbeans.org/web-main/rev/122c9a147dc2 yes, update feature isn't full yet and will not be full in 6.9 it hande only initially generated code and also some minor changes for now. feel free to file separate issue/enhancement for better update support. |