max wrote:
those names are not valid java...
I use (generated with middlegen for hibernate2 and after changing the DOCTYPE in the hbm.xml-files from hibernate2 to hibernate3 currently running with hiberate-3.1.3) classnames like "pdc$taItem" or "pdc$taStatus" in Java (1.4.2 and 1.5) since more then one year and everything works fine. And from
Sun's Java Tutorial clause "Naming":
Quote:
Variable names are case-sensitive. A variable's name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character "_". The convention, however, is to always begin your variable names with a letter, not "$" or "_". Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it's technically legal to begin your variable's name with "_", this practice is discouraged. White space is not permitted.
so, using the "$" is not notallowed ("should be avoid" is not "must be avoid" in my mind and it's autogenerated)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
max wrote:
how did you rename the abc$ta_tab_1 in middlegen
Take an editor (in this case "Kate") and replaced "." with "$" :-)
All jokes aside. I have e.g. 2 tables in my oracle-db: "PDC$TA_ITEM" and "PDC$TA_STATUS", with a foreign key references from "PDC$TA_ITEM" to "PDC$TA_STATUS". In my build.xml-File, I specified
Code:
<jdbcconfiguration packagename="com.foo.bar" />
The with
hbm2hbmxml generated hbm.xml-Files named "pdc$taItem.hbm.xml" and "pdc$taStatus.hbm.xml". Because of the reference, the file "pdc$taItem.hbm.xml" contains amongst others following code:
Code:
<many-to-one name="taStatus" class="com.foo.bar.pdc.taStatus">
<column name="STATUS_ID" />
</many-to-one>
Because i have a little bit notion of hbm.xml-files, i recognized, that
com.foo.bar.pdc.taStatus are wrong. So I changed it to
com.foo.bar.pdc$taStatus by hand, the spelling I know from middlegen for hibernate and run
hbm2java. The ant-task generated all java-classes without errors. But when i opened the java-files with eclipse, I noticed that
hbm2java genereted the following code in "taItem":
Code:
import com.foo.bar.pdc.taStatus;
When I change these to
"import com.foo.bar.taStatus;, everything was fine in eclipse. But til now I had no opportunity presented itself for real-testing the generated javacode.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At that time I started with
hibernate2 and
middlegen for hibernate, I did the same steps as now: existing db-schema -> hbm.xml-files -> java-classes. Unlike now the genereted
hbm.xml-files called
pdc_taItem.hbm.xml / pdc_taStatus.hbm.xml instead of
pdc$taItem.hbm.xml / pdc$taStatus.hbm.xml today. And the generated
JavaClasses called
pdc$taItem.java / pdc$taStatus.java instead of
taItem.java / taStatus.java today. When I don't want my JavaClasses named like the db-tables, I would specify an other name in the file "hibernate.reveng.xml".
In my mind as long as the names of the db-tables are valid JavaNames, they shouldn't be changed. If the names aren't valid JavaNames, throw an error while reverse engineering like "object name xyz is not a valid javaname. you have to specify a valid javaname in the hibernate.reveng.xml-file for these object."
best reguards
rig