Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.1
Mapping documents:
The account mapping file
<class
name="com.maintenance.Account"
table="account"
>
<id
name="account"
type="java.lang.String"
column="account"
>
<meta attribute="use-in-equals">true</meta>
<generator class="assigned" />
</id>
<property
name="status"
type="java.lang.String"
column="status_"
not-null="true"
length="1"
<property
name="accountType"
type="java.lang.String"
column="account_type"
not-null="true"
length="1"
/>
<property
name="omniType"
type="java.lang.String"
column="omni_type"
not-null="true"
length="1"
/>
The Dictionary mapping file
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.maintenance.Dictionary"
table="dictionary"
>
<cache usage="read-only"/>
<composite-id name="comp_id" class="com.maintenance.Dictiona
ryPK">
<key-property
name="DictCode"
column="dict_code"
/>
<key-property
name="SubCode"
column="sub_code"
/>
</composite-id>
<property
name="codeDesc"
type="java.lang.String"
column="code_desc"
not-null="true"
length="30"
/>
<property
name="subDesc"
type="java.lang.String"
column="sub_desc"
not-null="true"
length="30"
/>
<property
name="updateUser"
type="java.lang.String"
column="update_user"
not-null="true"
length="12"
/>
<property
name="updateDate"
type="java.sql.Timestamp"
column="update_date"
not-null="true"
length="26"
/>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Ingres 2.6
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
I have following tables in a legacy database
There is table account which has account as a unique key. It also has other columns like account_type,name etc. There is table dictionary which has unique keys as dict_code and sub_code. There is a primary key class generated by middlegen for this releationship. The query for selecting all accounts is as foll:
select a.* from account a,dictionary b
where a.account_type=b.sub_code
and b.dict_code ='ACCT'
How do I define the relationship in the mapping so that I can avoid direct SQL? Is it possible or should I settle for createSQLQuery()?