Part of entity:
Code:
public class Shortcut extends IRepositoryObject {
// more code
@ManyToOne(fetch = FetchType.LAZY, optional=true, cascade=CascadeType.REFRESH)
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(formula=@JoinFormula(value=CONTENT_ID_FIELD, referencedColumnName=UUID))
})
private Content providerContent;
// getters and setters
}
And I have a code:
Code:
Shortcut shortcut = basicRepository.findOne(Shortcut.class, 407);
log.info("get provider");
log.info("provider content: {}", shortcut.getProviderContent());
and log:
Quote:
Hibernate: select shortcut0_.id as id5_0_, shortcut0_.created_at as created3_5_0_, shortcut0_.updated_at as updated4_5_0_, shortcut0_.name as name5_0_, shortcut0_.title as title5_0_, shortcut0_.fk_parent_id as fk21_5_0_, shortcut0_."path" as path7_5_0_, shortcut0_.position as position5_0_, shortcut0_.accept as accept5_0_, shortcut0_.adult as adult5_0_, shortcut0_.deleted_at as deleted11_5_0_, shortcut0_.deleted as deleted5_0_, shortcut0_.hidden as hidden5_0_, shortcut0_.validity_to_date as validity14_5_0_, shortcut0_.validity_from_date as validity15_5_0_, shortcut0_.target as target5_0_, shortcut0_.version as version5_0_, shortcut0_.cost as cost5_0_, shortcut0_.op_ext_id as op18_5_0_, shortcut0_.preview as preview5_0_, shortcut0_.content_id as content20_5_0_, shortcut0_.content_id as formula1_0_ from OBJECT shortcut0_ where shortcut0_.id=? and shortcut0_.target='SHORTCUT'
Hibernate: select content0_.content_type as content1_0_0_, content0_.ext_id as ext2_0_0_, content0_.fk_provider_id as fk21_0_0_, content0_.provider_price as provider3_0_0_, content0_.adult as adult0_0_, content0_.created_at as created5_0_0_, content0_.hash as hash0_0_, content0_.name as name0_0_, content0_.fk_parent_content_type as fk22_0_0_, content0_.fk_parent_id as fk23_0_0_, content0_.fk_parent_provider_id as fk24_0_0_, content0_.fk_parent_price as fk25_0_0_, content0_.FK_PRICE_CATEGORY_ID as FK26_0_0_, content0_.priority as priority0_0_, content0_.title as title0_0_, content0_.updated_at as updated10_0_0_, content0_.uuid as uuid0_0_, content0_.accept as accept0_0_, content0_.deleted as deleted0_0_, content0_.deleted_at as deleted14_0_0_, content0_.description as descrip15_0_0_, content0_.hidden as hidden0_0_, content0_.preview as preview0_0_, content0_.stkPage as stkPage0_0_, content0_.validity_to_date as validity19_0_0_, content0_.validity_from_date as validity20_0_0_ from PROVIDER_CONTENT content0_ where content0_.uuid=?
INFO ru.icb.liteicms.service.DomainTest.test(DomainTest.java:29) : 2012-05-24 16:54:04,724 - get provider
INFO ru.icb.liteicms.service.DomainTest.test(DomainTest.java:31) : 2012-05-24 16:54:04,724 - provider content: ru.icb.liteicms.domain.Content@edb15a
Why LAZY sql query not work???