-->
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.  [ 4 posts ] 
Author Message
 Post subject: Second-Level Cache and PKs
PostPosted: Tue Apr 22, 2008 12:35 pm 
Newbie

Joined: Tue Apr 22, 2008 12:08 pm
Posts: 3
First of all: We are using Hibernate since almost 2 years and are very happy with it!

We are now in the need of integrating a Master-Slave replication in our existing PostgreSQL server. For now we are still evaluating possible solutions and want to give SkyTools a try.

Unfortunately SkyTools does not work with tables, consisting of multi column primary keys. We have approx. 5-10 tables that have primary keys with 2 or more columns and are mapped by Hibernate. To get rid of those multi column pks we'd add a new synthetic key (+ sequence) to the affected tables and switch the pk to the new synthetic key.

We rely on the second-level cache a lot and still want to benefit from it, after converting the existing tables. And therefore we'd like to know the following:

1. Does the second-level cache merely rely on the pk, set in the table?
2. If not, can Hibernate be configured to use other columns as the ones defined in the pk?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 3:03 am 
Regular
Regular

Joined: Mon Aug 06, 2007 10:49 am
Posts: 67
Location: Banska Bystrica, Slovakia
1.yes second level cache rely on primary key mapped for entity

2. u can specify in mapping natural-id - alternative key in db - and u can retrieved object from 2nd level cache by this natural id like this: http://www.hibernate.org/hib_docs/v3/re ... -naturalid


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 12:53 pm 
Newbie

Joined: Tue Apr 22, 2008 12:08 pm
Posts: 3
ferozz wrote:
1.yes second level cache rely on primary key mapped for entity

2. u can specify in mapping natural-id - alternative key in db - and u can retrieved object from 2nd level cache by this natural id like this: http://www.hibernate.org/hib_docs/v3/re ... -naturalid


Thanks for your quick reply!

I didn't know until now that there such a thing like <natural-id> exists. ("Hibernate in Action" does not mention it by any word.)

But to let <natural-id>s work, I'm forced to use criteria syntax, right?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 2:26 am 
Regular
Regular

Joined: Mon Aug 06, 2007 10:49 am
Posts: 67
Location: Banska Bystrica, Slovakia
hmm i dont know how to write it in hql or if it is possible


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