Sometimes there’s an easier way
Posted by danielmeyer on December 2, 2008
I was working to get snapshots of the Hibernate AnnotationConfiguration properties in effect when Hibernate local transactions are in use versus when a JTA transaction manager is in use, and halfway through I found there was a much easier way to capture my data.
What I did First
- While a debugging session was stopped at a breakpoint at line 732 of org.springframework.orm.hibernate3.LocalSessionFactoryBean (In buildSessionFactory() where the AnnotationConfiguration is done being built), I went to the Expressions view and selected the AnnotationConfiguration named “config”;
- Opened config’s properties field and manually expanded all 116 nodes, exposing their key/value pairs;
- Selected the 116 nodes-with-key/value-pairs and chose Copy Expressions from the context menu;
- Pasted into Notepad and manually removed the “[0...99]” and “[100...116]” lines;
- Saved the modified file as hibernate-annotation-config-jta.txt
- Ran the following commands:
egrep --invert-match "\[" hibernate-annotation-config-jta.txt > keys-values.txt egrep key= keys-values.txt | sed 's/[ \t]*key= \"\(.*\)\".*$/\1/' > keys.txt egrep value= keys-values.txt | sed 's/[ \t]*value= \"\(.*\)\".*$/\1/' > values.txt paste --delimiter== keys.txt values.txt > keys-values-jta.txt
This worked — it got all 116 entries into key=value format, one key/value pair per line — and I prepared to do it again while running my test in Hibernate mode.
Then I noticed…
Then I saw another pane in the Expressions view I hadn’t really noticed before, on the right hand side. When I clicked on one of the AnnotationConfig’s properties in the Expressions window (even without expanding that entry to show the key and value), I saw the entry in key=value format over in that right hand pane. And… if I selected all 116 nodes in the left pane of the Expressions view, all 116 key=value pairs showed up in the right pane, ready for me to select and copy!
My new workflow, then, is:
- While a debugging session is stopped at a breakpoint at line 732 of org.springframework.orm.hibernate3.LocalSessionFactoryBean (In buildSessionFactory() where the AnnotationConfiguration is done being built), go to the Expressions view, select the AnnotationConfiguration named “config”, and within that select the properties field;
- Make sure the “Show Logical Structure” button is pressed;
- Expand the properties field so that you can see the individual ,  … entries
- Select all these entries:
- In the Expressions view’s right hand pane, Select All and copy.
Those are nicer steps than what I did first! Eclipse comes through again!