-->
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.  [ 1 post ] 
Author Message
 Post subject: EAGER fetching on foreign keys unavoidable during inserts?
PostPosted: Mon May 03, 2010 1:05 pm 
Newbie

Joined: Sun Jul 10, 2005 10:20 am
Posts: 17
Location: London
Hi all,

I have got an (@Embeddable) entity (Address) with a FK to a fully flagged reference entity (Country). Everything is working ok, however I can see that before each insert into Address, a select on Country occurs as the following log demonstrates:

    Hibernate:
    /* get current state uk.co.jemos.persistence.domain.reference.Country */ select
    country_.COUNTRY_ID
    from
    COUNTRY country_
    where
    country_.COUNTRY_ID=?
    Hibernate:
    /* insert uk.co.jemos.persistence.domain.user.User
    */ insert
    into
    USERS
    (ADDRESS_LINE1, ADDRESS_LINE2, CITY, COUNTRY_ID, POSTCODE, COUNTY_STATE, `EMAIL`, `FULL_NAME`, `USERNAME`, VERSION_NBR)
    values
    (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


I guess this SQL occurs just to validate the FK right? E.g. that the country exists before inserting Address. Does this mean that the only way to get rid of the SELECT for each INSERT is to remove the FK? I wanted to use something like Session.load() where I just specify the country id and I'll tell HB to consider as if the country id was there, without a trip to the database, but I guess this wouldn't be optimal/supported?

Thanks & Regards,

M.


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

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.