I'm sure this is simple, but I keep going round and round on this. I have a very simple, legacy relationship
Code:
clients
-------
id
dms_type
dms_types
------------
id
name
When I query for a clients object, I don't want the dms_type ID. I want the the client object to contain the DMS name. I've tried many different mapping configurations. THe one that get's me the closest is this one:
Code:
<class name = "Clients" table="clients">
<id name="id" type="int" column="id" unsaved-value="0">
<generator class="native"/>
</id>
<property name="dms" column="dms_type" type="integer"/>
<many-to-one name="dmsTypes" class="DmsTypes" column="crm_type" unique="true" insert="false" update="false"/>
</class?
And
Code:
<class name = "DmsTypes" table="dms_types">
<id name="id" type="int" column="id" unsaved-value="0">
<generator class="native"/>
</id>
<property name="name" column="name" type="string"/>
<one-to-one name="client" class="Clients" property-ref="dms"/>
</class>
When I run my tests, I see hibernate is trying to select all clients that have a clients.dms_type of some value. What I really want to happen is to have hibernate select all the dmsTypes (there will be only one) that have a crm_type.id of some value. Can someone point out what I'm doing wrong?
Hibernate version: version 3.0.5, 25 May 2005
Name and version of the database you are using: postgreSQL 7.4
The generated SQL (show_sql=true): select clients0_.id as id0_, clients0_.name as name70_0_, clients0_.active as active70_0_, clients0_.internal as internal70_0_, clients0_.addr1 as addr5_70_0_, clients0_.addr2 as addr6_70_0_, clients0_.city as city70_0_, clients0_.state as state70_0_, clients0_.zip as zip70_0_, clients0_.phone as phone70_0_, clients0_.timezone as timezone70_0_, clients0_.dms_type as dms12_70_0_ from clients clients0_ where clients0_.dms_type=?