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.
When you rename Java Persistence entity names or entity fields/properties in NetBeans 5.5, the refactoring engine doesn't rename annotation metadata elements, resulting in deployment and runtime errors. For example, if I have a BankCustomer entity class with a persistent field customerId: @Entity @Table(name = "BANK_CUSTOMER") @NamedQueries( { @NamedQuery( name = "BankCustomer.FindByCustomerId", query = "SELECT a FROM BankCustomer a WHERE a.customerId = :customerId"), ... )} public class BankCustomer { ... @Id @GeneratedValue(strategy=GenerationType.TABLE, generator="customerIdGen") @Column(name = "CUSTOMER_ID", nullable = false) private String custoemrId; ... } And I want to rename the entity class to Customer, and customerId to id, the refactoring engine doesn't refactor the metadata: @Entity @Table(name = "BANK_CUSTOMER") @NamedQueries( { @NamedQuery( name = "BankCustomer.FindByCustomerId", query = "SELECT a FROM BankCustomer a WHERE a.customerId = :customerId"), ... )} public class Customer { ... @Id @GeneratedValue(strategy=GenerationType.TABLE, generator="customerIdGen") @Column(name = "CUSTOMER_ID", nullable = false) private String id; ... } There are three errors here: 1. The NamedQuery name doesn't match the entity class name and the renamed field. 2. The query is incorrect as it's schemaname is still BankCustomer, but should have been renamed to Customer. 3. The fields and named parameters in the query are also incorrect ("customerId" rather than "id"). The mappedBy element in relationship annotations are also not updated during refactoring, which results in deployment errors. The refactoring engine should update annotation metadata.
In my opinion this can be seen rather as a bug in J2EE refactoring. Besides, reassigning to appropriate component.
Changing subcomponent as well.
*** Issue 73925 has been marked as a duplicate of this issue. ***
I'm changing priority to P2 since this feature is very important for persitence stuff.
Partially fixed, mappedBy references should be now updated.
*** Issue 74540 has been marked as a duplicate of this issue. ***
Changing this to enhancement as agreed with Petr Blaha. Issue with mappedBy references is now resolved, and support for ejb-ql refactoring is something that has not been present in previous releases.
*** Issue 78606 has been marked as a duplicate of this issue. ***
Closed duplicate issue was from netcat - adding prefix here.
*** Issue 78634 has been marked as a duplicate of this issue. ***
2 duplicates filed in the past day - perhaps this should be a defect, not an enhancement? Also, be sure to see Jesse's comments on Issue 78634.
Since the original problem reported here is partially fixed, would it be useful to file a new issue with just the remaining part? Regarding a possible solution, would it be possible to display a warning to the user prompting her to manually update the NamedQueries?
nq refactoring isn't supported yet, but nqs are verified now and warning is shown if necessary, may work in this case (from 7.2)
mappedBy is implemented in 205539 as named queries parsing/completion etc is added in 7.2 it may be possible to add named queries refactoring later also.