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 161628 - ide automatically reformats hibernate's .hbm.xml files
Summary: ide automatically reformats hibernate's .hbm.xml files
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Hibernate (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Sergey Petrov
URL:
Keywords:
: 174044 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-03-31 19:37 UTC by gregkotsaftis
Modified: 2011-05-01 04:58 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NetBeans project file (14.51 KB, application/octet-stream)
2010-11-23 08:47 UTC, gregkotsaftis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gregkotsaftis 2009-03-31 19:37:23 UTC
This issue existed also in v6.5 as well in latest 6.5.1

In "Desing View" while editing a swing form, whenever I rename a variable e.g. a JButton jButton1 to myButton,
the ide automatically reformats any hibernate *.hbm.xml file wherever they exist in my project. All spaces, tabs are 
gone in the xml files, as well the order of tag properties changes. Needless to say this is really annoying. Luckily I 
use subversion and I find myself all day "reverting" all *.hbm.xml files.
Comment 1 gregkotsaftis 2009-03-31 19:41:06 UTC
please note that in nb 6.0 there was no such problem.
Comment 2 Tomas Pavek 2009-04-07 12:54:15 UTC
GUI builder has no reason to touch hibernate files. When renaming a variable, a rename refactoring is invoked (and all
files saved). Maybe the hibernate support is somewhat hooked into that. Should be evaluated by hibernate plugin owners.
Comment 3 Sergey Petrov 2009-07-29 11:18:33 UTC
ok, I tried next with latest nb, most likely should be the same in 6.7/

create web application with hibernate framework
create packag
add jpanel form
add a button
rename button name in navigator

hibernate.cfg.xml stay unaffected.

if the issue is reproducible, please provide more steps starting from project creation, and may be attach sample project.
Comment 4 gregkotsaftis 2009-09-18 13:29:21 UTC
I cannot say if this issue exists in nb 6.7 as we only use 6.5.1 for active development.
Try to create a simple SWING app (not a web application) and a couple of db tables in different *.hbm.xml files, e.g.
customer.hbm.xml, order.hbm.xml, etc. Create a simple panel with a couple of buttons/labels and save it. Format by hand
the *.hbm.xml files to make them pleasing to your eyes, save. Try to rename a button in "Desing View"  from e.g.
jButton1 to myButton. All *.hbm.xml are reformatted!
Comment 5 Sergey Petrov 2009-09-18 13:35:19 UTC
thanks, will reevaluate with new information
Comment 6 Sergey Petrov 2009-09-29 11:54:43 UTC
tried ith 6.7 and I'm not able to reproduce the issue.
if it's possible to save project open, rename button and god reformat it may be good to attach sucnh project. may be the
issue is fixed in 6.7+. or some important steps are still missed.
may be it was refactoring issue in 6.5. can you try 6.7?
Comment 7 gregkotsaftis 2009-09-30 08:55:56 UTC
I tried upgrading to 6.7.1 and it seems the problem is no more!
Please feel free to close this one!
Comment 8 Sergey Petrov 2009-09-30 09:10:22 UTC
thanks, resolved as working
Comment 9 gregkotsaftis 2010-11-22 12:25:43 UTC
I am sorry to say that after last weeks Netbean update, this has happened AGAIN!

I did a refactor/rename on a JInternalFrame and all my hibernate xml files were altered as well!

Product Version: NetBeans IDE 6.9.1 (Build 201011082200)
Java: 1.6.0_22; Java HotSpot(TM) Client VM 17.1-b03
System: Windows XP version 5.1 running on x86; Cp1253; el_GR (nb)
Comment 10 Sergey Petrov 2010-11-22 12:45:54 UTC
Is it always reproducible? Can you attach message.log? I'm not sure but there may be some information
Comment 11 gregkotsaftis 2010-11-23 08:47:25 UTC
Created attachment 103228 [details]
NetBeans project file
Comment 12 gregkotsaftis 2010-11-23 08:48:08 UTC
Comment on attachment 103228 [details]
NetBeans project file

We are lucky this time. It happens always. Check the attachment project.
Comment 13 Sergey Petrov 2010-11-26 11:24:26 UTC
ok, tried to refactor (rename) frame class and it removes empty lines, some newlines etc, it's good I can revert from local history, you can do the same instead of svn. Can  be considered as "nice" undocumented feature for free space optimization but anyway it's an issue.
Comment 14 Sergey Petrov 2010-11-26 12:52:54 UTC
org.netbeans.modules.hibernate.refactoring.JavaClassRenameTransaction::doChanges rewrite files for no visible reasons. Not sure yet how fast it can be fixed, but it's starting point for later investigation.
Comment 15 gregkotsaftis 2010-11-26 14:07:48 UTC
When i was just a young and new software engineer, i remember senior teammates to call this behavior as application's "hidden features" instead of "bugs" ;)

Anyway, it's good we managed to verify this, even after more than 1.5 years and almost 6 netbean's releases! Right now, i can easily revert using SVN. But you have to wonder to what other file types this happens as well. We only use hibernate xml files, but i guess this happens for other xml files too.
Comment 16 Sergey Petrov 2010-12-27 17:40:06 UTC
*** Bug 174044 has been marked as a duplicate of this bug. ***
Comment 17 Sergey Petrov 2011-03-18 16:56:46 UTC
http://hg.netbeans.org/web-main/rev/4c814d32a513 should rewrite only if there are any changes now
Comment 18 malfunction84 2011-04-29 22:40:22 UTC
I guess this didn't make it into 7.0, because I'm still seeing *.hbm.xml files being reformatted when I rename a class.

I wouldn't mind so much if it reformatted them using the rules I have defined under Tools > Options > Editor > Formatting.
Comment 19 Sergey Petrov 2011-05-01 04:58:44 UTC
yes. should go to 7.0.1, even if reformat is not so bad itself anyway fix should speed up refactoring as unnecessary file rewrite is skipped.