-->
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.  [ 3 posts ] 
Author Message
 Post subject: Cache one-to-one association from "mappedBy" side
PostPosted: Fri Jun 29, 2007 9:08 pm 
Newbie

Joined: Fri Jun 29, 2007 8:49 pm
Posts: 1
I'm wondering if there is a way to enable second-level cache to work for one-to-one association from "mappedBy" side (or non-owning side). Here is an example:

Appliance and Service are zero/one-to-one relationship, with Service being the owning side and Appliance specifies "mappedBy" clause.

Code snippet:

@Entity(name="Appliance")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class ApplianceImpl {
...
@OneToOne(targetEntity = ServiceImpl.class,
cascade = { CascadeType.ALL }, mappedBy = "appliance")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
private Service service;
...
}

@Entity(name="Service"
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class ServiceImpl {
...
@OneToOne(targetEntity = ApplianceImpl.class,
fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "idAppliance")
private Appliance appliance;
...
}

As you say see, cache is enabled on both entities and 'service' property on Appliance. But every time I use Appliance.service, it still go to DB to fetch the service (I did see both entities got added to second-level cache from the log).

This is causing performance problem to us, since we are referring to Appliance.service extremely frequently. We cannot change Appliance.service to @OneToMany, because there are many places actually search on "Appliance.service" property (so having Hiberate return a collection and return 'service' as a synthetic property won't work). And (to make things worse), lazy loading on Appliance.service won't work, since the one-to-one association is optional.

Any help? I googled quite a bit, and the only relevant info I found is this:

http://www.mail-archive.com/hibernate-d ... 05195.html

But I still don't see why caching the one-to-one association from the non-owning side would be so difficult...

BTW, I'm using Hibernate 3.2.0 and JBoss 4.0.5

Thanks,
-Ting


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 31, 2009 6:07 am 
Newbie

Joined: Tue Sep 02, 2003 3:14 pm
Posts: 11
Hi all,

I am bumping a pretty old topic but we are facing the very same issue and I wonder if there is some hope now in this regards ?

Thanks in advance,
Chris


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 14, 2009 1:16 am 
Newbie

Joined: Tue Sep 02, 2003 3:14 pm
Posts: 11
No one ? Come on ;)

I can't believe we are the only one with this use case and wanting to know if hib 3.4.x or 3.5.x is likely to be able handle this.

Thanks !


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