I use the latest release and I have this strange thing.
One entity, File, has this one-to-one mapping
Code:
<one-to-one name="visits" class="FileVisitCounter" property-ref="file" cascade="save-update" lazy="proxy"/>
The problem is that if I run a query like from File f
I see I bunch of selects for the visits.
Code:
select filevisitc0_.id as id93_0_, filevisitc0_.version as version93_0_, filevisitc0_.file_id as file3_93_0_, filevisitc0_.ip_address as ip4_93_0_, filevisitc0_.created_by as created5_93_0_, filevisitc0_.date_created as date6_93_0_, filevisitc0_.modified_by as modified7_93_0_, filevisitc0_.date_modified as date8_93_0_ from public.file_visit_counter filevisitc0_ where filevisitc0_.file_id=?
That's not right, if its lazy="proxy" shouldn't be fetched
If I run it like
Code:
from File file
left join fetch file.visits
Will do the trick but why should I have spend 100ms for the join ?
Thanks for looking and btw I don't specifically call the getter for visits and I don't update the visits.
Code:
<hibernate-mapping>
<class name="FileVisitCounter" table="file_visit_counter" schema="public" select-before-update="true">
<id name="id" type="integer">
<column name="id" />
<generator class="sequence">
<param name="sequence">file_visit_counter_id_seq</param>
</generator>
</id>
<version name="version" type="java.lang.Integer">
<column name="version" />
</version>
<many-to-one name="file" class="File" fetch="select">
<column name="file_id" not-null="true" unique="true" />
</many-to-one>
<property name="ipAddress" type="string">
<column name="ip_address" length="30" />
</property>
<property name="createdBy" type="string">
<column name="created_by" length="30" />
</property>
<property name="dateCreated" type="timestamp">
<column name="date_created" length="29" />
</property>
<property name="modifiedBy" type="string">
<column name="modified_by" length="30" />
</property>
<property name="dateModified" type="timestamp">
<column name="date_modified" length="29" />
</property>
</class>
</hibernate-mapping>
Code:
Code: