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 153968

Summary: hibernate-mapping's package ignored when refactoring
Product: javaee Reporter: malfunction84 <malfunction84>
Component: HibernateAssignee: Sergey Petrov <sj-nb>
Status: RESOLVED FIXED    
Severity: blocker CC: pjiricka
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 173299    

Description malfunction84 2008-11-26 21:00:57 UTC
The package attribute of the hibernate-mapping element is not considered when refactoring a class.

For instance, if my mapping file has the following...

<hibernate-mapping>
  <class name="my.package.pojo.User" table="users">
    <!-- SNIP -->
  </class>
</hibernate-mapping>

...and I refactor the User class to rename or move it, the mapping file is updated to match.  However, if my mapping
file has the following...

<hibernate-mapping package="my.package.pojo">
  <class name="User" table="users">
    <!-- SNIP -->
  </class>
</hibernate-mapping>

...and I perform the same refactoring as before on the User class, the mapping file isn't touched by the refactor process.
Comment 1 Vadiraj Deshpande 2008-11-27 18:29:42 UTC
package attribute need to be considered in Hyperlinking Java classes in mapping files.
Comment 2 Vadiraj Deshpande 2008-11-27 18:30:47 UTC
*** Issue 153969 has been marked as a duplicate of this issue. ***
Comment 3 Petr Cyhelsky 2009-10-23 09:00:17 UTC
after 8b098fa5a4f2 and 60a73e76253e this seems to function ok, please reopen with steps if encountered again
Comment 4 malfunction84 2010-03-04 14:33:39 UTC
Still not working.  The steps to reproduce are what you would expect (see the original description):
1. Create an entity bean class in a package.
2. Create a corresponding mapping file.
3. In the <hibernate-mapping> element, declare a "package" attribute with a value matching the class's package.
4. Instead of using the FQCN of the class in the "name" attribute of the <class> element, use just the simple class name.
5. Refactor (rename) the entity bean class.

When previewing the refactor, the mapping file does not shows up in the list of files to be modified.  Mapping files which reference the class by its FQCN do show up in the preview and are refactored correctly, but that happened already.

Also, Ctrl+clicking the class's name in the mapping file (e.g. User in <class name="User" table="users">) does not open the class.  Instead, the message "Source file User not found" appears in the status bar.  Really, it should be looking for my.package.pojo.User, using the value of the "package" attribute defined in the <hibernate-mapping> element.
Comment 5 malfunction84 2010-03-05 08:35:48 UTC
Somehow, I doubt this is going to make it into 6.8.
Comment 6 Sergey Petrov 2011-03-21 14:37:09 UTC
still valid, seems easy to fix but with a lot of changes.
Comment 7 Sergey Petrov 2012-05-18 20:54:21 UTC
it's kind of issue 4 in 1 or more, 
hiperlink is fixed, usages is fixed, rename is fixed, need to check 'move'
http://hg.netbeans.org/web-main/rev/51508004e837
http://hg.netbeans.org/web-main/rev/747b6900a1d6
http://hg.netbeans.org/web-main/rev/fefd47370685
Comment 8 Sergey Petrov 2012-05-21 09:33:41 UTC
http://hg.netbeans.org/web-main/rev/60dd1c823c0d
if any more issues will be found in the area, please file as separate issues to avoid all in one issue.
Comment 9 Quality Engineering 2012-05-22 16:20:49 UTC
Integrated into 'main-golden', will be available in build *201205220903* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/51508004e837
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #153968 hiperlink for class name