Hibernate 2.1.1 generates the select statement below;
I'm getting a jdbc "Invalid field name" message when it executes.
It seems the where clause is using the name of the java field
instead of the name of the sql field to do the query.
When underscores are added to the field name in the where clause
so it reads "where (current_First_Name like 'Test%' )",
instead of "where (currentFirstName like 'Test%' )",
everything works fine in a sqlplus window (using Oracle9).
Java class code is generated by hbm2java
and sql "create table" ddl is generated by SchemaExport,
by the mapping file (included following the select).
As far as I can see the mapping is OK (but have mercy; I'm a newbie).
Is this a bug or is it me? What do I do next?
Thanks in advance,
Sandy
select
person0_.ID as id,
person0_.CURRENT_LAST_NAME as CURRENT_2_54_,
person0_.CURRENT_FIRST_NAME as CURRENT_3_54_,
person0_.CURRENT_MIDDLE_NAME as CURRENT_4_54_,
person0_.CURRENT_PERSONAL_TITLE as CURRENT_5_54_,
person0_.CURRENT_SUFFIX as CURRENT_6_54_,
person0_.CURRENT_NICKNAME as CURRENT_7_54_,
person0_.GENDER as GENDER54_,
person0_.BIRTH_DATE as BIRTH_DATE54_,
person0_.HEIGHT as HEIGHT54_,
person0_.WEIGHT as WEIGHT54_,
person0_.MOTHERS_MAIDEN__NAME as MOTHERS12_54_,
person0_.MARTIAL_STATUS as MARTIAL13_54_,
person0_.SOCIAL_SECURITY_NUMBER as SOCIAL_14_54_,
person0_.CURRENT_PASSPORT_NUMBER as CURRENT15_54_,
person0_.CURRENT_PASSPORT_EXPIRE_DATE as CURRENT16_54_,
person0_.TOTAL_YEARS_WORK_EXPERIENCE as TOTAL_Y17_54_,
person0_.COMMENTS as COMMENTS54_,
person0__1_.CREATED_ON_DATE as CREATED_2_50_,
person0__1_.CREATED_ON_TIME as CREATED_3_50_,
person0__1_.CREATED_BY as CREATED_BY50_,
person0__1_.UPDATED_ON_DATE as UPDATED_5_50_,
person0__1_.UPDATED_ON_TIME as UPDATED_6_50_,
person0__1_.UPDATED_BY as UPDATED_BY50_,
person0__1_.REVISION as REVISION50_
from PERSON person0_
inner join PARTY person0__1_ on person0_.ID=person0__1_.id
where (currentFirstName like 'Test%' )
;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- Party is the root class for Person and Organization. -->
<class name="com.genco.xxx.component.Party" table="PARTY">
<id name="id" type="string" unsaved-value="null">
<column name="id" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property column="CREATED_ON_DATE" length="7" name="createdOnDate" type="java.sql.Timestamp"/>
<property column="CREATED_ON_TIME" length="7" name="createdOnTime" type="java.sql.Timestamp"/>
<property column="CREATED_BY" length="50" name="createdBy" type="java.lang.String"/>
<property column="UPDATED_ON_DATE" length="7" name="updatedOnDate" type="java.sql.Timestamp"/>
<property column="UPDATED_ON_TIME" length="7" name="updatedOnTime" type="java.sql.Timestamp"/>
<property column="UPDATED_BY" length="50" name="updatedBy" type="java.lang.String"/>
<property column="REVISION" length="8" name="revision" type="int"/>
<!-- Party plays a set of PartyRoleTypes -->
<!--
<set name="Roles" table="PARTY_ROLE">
<key column="PARTY_ID"/>
<many-to-many class="com.genco.xxx.component.PartyRoleType" column="PARTY_ROLE_TYPE_ID"/>
</set>
-->
<!-- Party has a set of PartyRoles -->
<set name="partyRoles" table="PARTY_ROLE">
<key column="PARTY_ID"/>
<one-to-many class="com.genco.xxx.component.PartyRole"/>
</set>
<!-- Organization is a subclass of Party -->
<joined-subclass name="com.genco.xxx.component.Organization" table="ORG">
<key column="ID"/>
<property column="NAME" length="40" name="name" type="java.lang.String"/>
<!-- Organization has a set of child Organizations -->
<set name="childOrganizations" table="ORG">
<key column="PARENT_ORG_ID"/>
<one-to-many class="com.genco.xxx.component.Organization"/>
</set>
<!-- Organization has one parent Organization -->
<many-to-one name="parentOrganization" class="com.genco.xxx.component.Organization" column="PARENT_ORG_ID"/>
<!-- LegalOrganization is a subclass of Organization -->
<joined-subclass name="com.genco.xxx.component.LegalOrganization" table="LEGAL_ORG">
<key column="ID"/>
<property column="BUSINESS_NUMBER" length="40" name="businessNumber" type="java.lang.String"/>
</joined-subclass>
<!-- InformalOrganization is a subclass of Organization -->
<joined-subclass name="com.genco.xxx.component.InformalOrganization" table="INFORMAL_ORG">
<key column="ID"/>
</joined-subclass>
</joined-subclass>
<!-- Person is a subclass of Party. -->
<joined-subclass name="com.genco.xxx.component.Person" table="PERSON">
<key column="ID"/>
<property column="CURRENT_LAST_NAME" length="40" name="currentLastName" type="java.lang.String"/>
<property column="CURRENT_FIRST_NAME" length="40" name="currentFirstName" type="java.lang.String"/>
<property column="CURRENT_MIDDLE_NAME" length="40" name="currentMiddleName" type="java.lang.String"/>
<property column="CURRENT_PERSONAL_TITLE" length="40" name="currentPersonalTitle" type="java.lang.String"/>
<property column="CURRENT_SUFFIX" length="40" name="currentSuffix" type="java.lang.String"/>
<property column="CURRENT_NICKNAME" length="40" name="currentNickname" type="java.lang.String"/>
<property column="GENDER" length="1" name="gender" type="java.lang.String"/>
<property column="BIRTH_DATE" length="7" name="birthDate" type="java.sql.Timestamp"/>
<property column="HEIGHT" length="8" name="height" type="int"/>
<property column="WEIGHT" length="8" name="weight" type="int"/>
<property column="MOTHERS_MAIDEN__NAME" length="40" name="mothersMaidenName" type="java.lang.String"/>
<property column="MARTIAL_STATUS" length="1" name="martialStatus" type="java.lang.String"/>
<property column="SOCIAL_SECURITY_NUMBER" length="8" name="socialSecurityNumber" type="int"/>
<property column="CURRENT_PASSPORT_NUMBER" length="8" name="currentPassportNumber" type="int"/>
<property column="CURRENT_PASSPORT_EXPIRE_DATE" length="7"
name="currentPassportExpireDate" type="java.sql.Timestamp"/>
<property column="TOTAL_YEARS_WORK_EXPERIENCE" length="8"
name="totalYearsWorkExperience" type="int"/>
<property column="COMMENTS" length="255" name="comments" type="java.lang.String"/>
</joined-subclass>
</class>
</hibernate-mapping>
|