-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Fetching one-to-one , why ?
PostPosted: Wed Jun 13, 2007 12:29 am 
Newbie

Joined: Wed Jun 06, 2007 11:58 am
Posts: 13
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:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 25, 2007 6:49 pm 
Newbie

Joined: Wed Jun 06, 2007 11:58 am
Posts: 13
Just wanted to add I don't do no changes to the FileVisitCounter so select before update should not be a player into this one...

Similar for File - I don't modify the file that's associated with the visit.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.