-->
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.  [ 5 posts ] 
Author Message
 Post subject: Loading ALL objects in Cache... too many requests
PostPosted: Mon May 24, 2004 4:15 am 
Beginner
Beginner

Joined: Wed May 12, 2004 4:27 am
Posts: 21
Location: Montreux (CH)
Hello,

I use Hibernate and EHCache.

Imagine I have the following entities : Team, Player and a many-to-many relationship stored in Team_x_Player

I would like to load in Cache everything at startup.
I can do a
From Team
From Player
From Team_x_Player

if I put lazy="false" into my relationship, I will have as many jdbc requests as I've got team or players ;o(
And if I put lazy to true, then when I do myteam.getPlayers(), it still does a jdbc request although all data should be in cache...

any idea ??


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 5:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
use "fetch join" clause in your HQL.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 6:07 am 
Beginner
Beginner

Joined: Wed May 12, 2004 4:27 am
Posts: 21
Location: Montreux (CH)
michael wrote:
use "fetch join" clause in your HQL.


first, thank you very much !

I don't want to make you loose your time..
but can you explain more ?
If I do at startup the correct HQL request, all will be in cache ?

how do I have to do for this kind of relationships (A is an entity, AxA stores the parent/child relationship for A, and A_info is a one-to-many relationship for A). Is there a way to load this at once ?
Where can I have more help on HQL syntax and examples ?

A
=====
id
name

AxA
=======
parent_A_id
child_A_id
type

A_info
=======
A_id
param1
param2


Top
 Profile  
 
 Post subject: find("From A,B,C") then load(A,id) ... does not us
PostPosted: Mon May 24, 2004 8:43 am 
Beginner
Beginner

Joined: Wed May 12, 2004 4:27 am
Posts: 21
Location: Montreux (CH)
I've spent the whole day trying to load all my objects at startup..

it works if I load them with lazy=false BUT
it loads them one by one... so it takes 2 minutes for my 10,000 objects ;o(

it should last at maximum 10 seconds for this if I would do it in one time
(select id, name from A, select parent_A_id, child_A_id from B, select A_id, value from C) .. and them association..

if anyone has a solution....

I was said to use fetch join

but with no success ;o(

it does the correct request, but after, when I load an object, it does not use the cache at all..

thank you


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 11:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
which release are you using? fetch join is done for this!
show hql you've written

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.