[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink caching behaviour

May be following code snippet helps you

I have positive result with the following usage

@Entity
@Cache (
	    type=CacheType.WEAK,
	    expiry=600000,
	    alwaysRefresh =true,
	    disableHits=false,
	    coordinationType=CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES
	    )
@NamedQueries( {
		@NamedQuery(name = "CodFlexCodesB.findAll", 
		            query = "select o from CodFlexCodesB o"),
		@NamedQuery(name  = "CodFlexCodesB.timeValidity", 
				    query = "SELECT em FROM CodFlexCodesB em " +
				    		"WHERE em.codFlexCodeSystemsB.id =  :id AND " +
				    		"(em.startDate <= :endDate) AND (em.endDate >= :startDate OR 
em.endDate IS NULL) ",
				    hints = @QueryHint(name=QueryHints.CACHE_USAGE,
value=CacheUsage.ConformResultsInUnitOfWork )
				    
				   )
})

Yes, if I see my log it does shows the query being hit many time. I think
its querying object not DB (please verify. It should you show the same thing
in Hibernate also)

[Eclipselink team please verify my assumptons]

EL Fine]: 2008.08.05
11:35:30.843--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--SELECT
ID, CODE, CREATED_BY, CREATION_DATE, DESCR, INSTALLED_FLAG, LAST_UPDATED_BY,
LAST_UPDATED_DATE, LAST_UPDATE_LOGIN, NLS_LANGUAGE, OBJECT_VERSION_NUMBER,
STATUS_ID FROM OHI_LANGUAGES
[EL Fine]: 2008.08.05
11:35:30.859--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--SELECT
COD_FLEX_CODE_S1.NEXTVAL FROM DUAL
[EL Fine]: 2008.08.05
11:35:30.875--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--SELECT
ID FROM COD_FLEX_CODE_SYSTEMS_B WHERE (ID = ?)
	bind => [10001]
[EL Fine]: 2008.08.05
11:35:30.875--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--INSERT
INTO COD_FLEX_CODES_B (ID, CREATED_BY, CREATION_DATE, END_DATE,
LAST_UPDATED_BY, LAST_UPDATED_DATE, LAST_UPDATE_LOGIN,
OBJECT_VERSION_NUMBER, START_DATE, VALUE_DATE1, VALUE_DATE2, VALUE_DATE3,
VALUE_DATE4, VALUE_DATE5, VALUE_DATE6, VALUE_DATE7, VALUE_DATE8, VALUE_NR1,
VALUE_NR2, VALUE_NR3, VALUE_NR4, VALUE_NR5, VALUE_NR6, VALUE_NR7, VALUE_NR8,
FCSY_ID, FLCO_ID8, FLCO_ID3, STATUS_ID, FLCO_ID1, FLCO_ID7, FLCO_ID9,
FLCO_ID4, FLCO_ID6, FLCO_ID2, FLCO_ID5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?)
	bind => [9548, 1217928930828, 2008-08-05 11:35:30.828, 2008-08-15
11:35:30.828, 1217928930828, 2008-08-05 11:35:30.828, test, 1, 2008-08-05
11:35:30.828, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, 10001, null, null, null, null, null,
null, null, null, null, null]
[EL Fine]: 2008.08.05
11:35:30.875--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--INSERT
INTO COD_FLEX_CODES_TL (LANGUAGE, CREATED_BY, CREATION_DATE, KEY_VALUE,
LAST_UPDATED_BY, LAST_UPDATED_DATE, LAST_UPDATE_LOGIN,
OBJECT_VERSION_NUMBER, SOURCE_LANG, VALUE_CHAR1, VALUE_CHAR2, VALUE_CHAR3,
VALUE_CHAR4, VALUE_CHAR5, VALUE_CHAR6, VALUE_CHAR7, VALUE_CHAR8, ID) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
	bind => [US, 1217928930828, 2008-08-05 11:35:30.828, GMTEst, 1217928930828,
2008-08-05 11:35:30.828, test, 1, NL, null, null, null, null, null, null,
null, null, 9548]
[EL Fine]: 2008.08.05
11:35:30.890--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--INSERT
INTO COD_FLEX_CODES_TL (LANGUAGE, CREATED_BY, CREATION_DATE, KEY_VALUE,
LAST_UPDATED_BY, LAST_UPDATED_DATE, LAST_UPDATE_LOGIN,
OBJECT_VERSION_NUMBER, SOURCE_LANG, VALUE_CHAR1, VALUE_CHAR2, VALUE_CHAR3,
VALUE_CHAR4, VALUE_CHAR5, VALUE_CHAR6, VALUE_CHAR7, VALUE_CHAR8, ID) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
	bind => [NL, 1217928930828, 2008-08-05 11:35:30.828, GMTEst, 1217928930828,
2008-08-05 11:35:30.828, test, 1, NL, null, null, null, null, null, null,
null, null, 9548]
[EL Fine]: 2008.08.05
11:35:30.890--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--SELECT
t1.ID, t1.CREATED_BY, t1.CREATION_DATE, t1.END_DATE, t1.LAST_UPDATED_BY,
t1.LAST_UPDATED_DATE, t1.LAST_UPDATE_LOGIN, t1.OBJECT_VERSION_NUMBER,
t1.START_DATE, t1.VALUE_DATE1, t1.VALUE_DATE2, t1.VALUE_DATE3,
t1.VALUE_DATE4, t1.VALUE_DATE5, t1.VALUE_DATE6, t1.VALUE_DATE7,
t1.VALUE_DATE8, t1.VALUE_NR1, t1.VALUE_NR2, t1.VALUE_NR3, t1.VALUE_NR4,
t1.VALUE_NR5, t1.VALUE_NR6, t1.VALUE_NR7, t1.VALUE_NR8, t1.FCSY_ID,
t1.FLCO_ID8, t1.FLCO_ID3, t1.STATUS_ID, t1.FLCO_ID1, t1.FLCO_ID7,
t1.FLCO_ID9, t1.FLCO_ID4, t1.FLCO_ID6, t1.FLCO_ID2, t1.FLCO_ID5 FROM
COD_FLEX_CODE_SYSTEMS_B t0, COD_FLEX_CODES_B t1 WHERE ((((t0.ID = ?) AND
(t1.START_DATE <= ?)) AND ((t1.END_DATE >= ?) OR (t1.END_DATE IS NULL))) AND
(t0.ID = t1.FCSY_ID))
	bind => [10001, 2008-08-15 11:35:30.828, 2008-08-05 11:35:30.828]
Size 1
[EL Fine]: 2008.08.05
11:35:30.890--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--SELECT
t1.ID, t1.CREATED_BY, t1.CREATION_DATE, t1.END_DATE, t1.LAST_UPDATED_BY,
t1.LAST_UPDATED_DATE, t1.LAST_UPDATE_LOGIN, t1.OBJECT_VERSION_NUMBER,
t1.START_DATE, t1.VALUE_DATE1, t1.VALUE_DATE2, t1.VALUE_DATE3,
t1.VALUE_DATE4, t1.VALUE_DATE5, t1.VALUE_DATE6, t1.VALUE_DATE7,
t1.VALUE_DATE8, t1.VALUE_NR1, t1.VALUE_NR2, t1.VALUE_NR3, t1.VALUE_NR4,
t1.VALUE_NR5, t1.VALUE_NR6, t1.VALUE_NR7, t1.VALUE_NR8, t1.FCSY_ID,
t1.FLCO_ID8, t1.FLCO_ID3, t1.STATUS_ID, t1.FLCO_ID1, t1.FLCO_ID7,
t1.FLCO_ID9, t1.FLCO_ID4, t1.FLCO_ID6, t1.FLCO_ID2, t1.FLCO_ID5 FROM
COD_FLEX_CODE_SYSTEMS_B t0, COD_FLEX_CODES_B t1 WHERE ((((t0.ID = ?) AND
(t1.START_DATE <= ?)) AND ((t1.END_DATE >= ?) OR (t1.END_DATE IS NULL))) AND
(t0.ID = t1.FCSY_ID))
	bind => [10001, 2008-08-26 11:35:30.89, 2008-08-16 11:35:30.89]
>>>>><<<<< false
Size 0
[EL Fine]: 2008.08.05
11:35:30.890--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--SELECT
t1.ID, t1.CREATED_BY, t1.CREATION_DATE, t1.END_DATE, t1.LAST_UPDATED_BY,
t1.LAST_UPDATED_DATE, t1.LAST_UPDATE_LOGIN, t1.OBJECT_VERSION_NUMBER,
t1.START_DATE, t1.VALUE_DATE1, t1.VALUE_DATE2, t1.VALUE_DATE3,
t1.VALUE_DATE4, t1.VALUE_DATE5, t1.VALUE_DATE6, t1.VALUE_DATE7,
t1.VALUE_DATE8, t1.VALUE_NR1, t1.VALUE_NR2, t1.VALUE_NR3, t1.VALUE_NR4,
t1.VALUE_NR5, t1.VALUE_NR6, t1.VALUE_NR7, t1.VALUE_NR8, t1.FCSY_ID,
t1.FLCO_ID8, t1.FLCO_ID3, t1.STATUS_ID, t1.FLCO_ID1, t1.FLCO_ID7,
t1.FLCO_ID9, t1.FLCO_ID4, t1.FLCO_ID6, t1.FLCO_ID2, t1.FLCO_ID5 FROM
COD_FLEX_CODE_SYSTEMS_B t0, COD_FLEX_CODES_B t1 WHERE ((((t0.ID = ?) AND
(t1.START_DATE <= ?)) AND ((t1.END_DATE >= ?) OR (t1.END_DATE IS NULL))) AND
(t0.ID = t1.FCSY_ID))
	bind => [10001, 2008-07-25 11:35:30.89, 2008-07-26 11:35:30.89]
Size 0
[EL Fine]: 2008.08.05
11:35:30.890--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--DELETE
FROM COD_FLEX_CODES_TL WHERE ((ID = ?) AND (LANGUAGE = ?))
	bind => [9548, US]
[EL Fine]: 2008.08.05
11:35:30.890--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--DELETE
FROM COD_FLEX_CODES_TL WHERE ((ID = ?) AND (LANGUAGE = ?))
	bind => [9548, NL]
[EL Fine]: 2008.08.05
11:35:30.890--ClientSession(2347637)--Connection(30283254)--Thread(Thread[main,5,main])--DELETE
FROM COD_FLEX_CODES_B WHERE (ID = ?)
	bind => [9548]




elygre wrote:
> 
> I'm working on understanding the eclipselink cache, and I still have quite
> a
> way to go J
> 
>  
> 
> I have an entity with a single column primary key (String). If i use
> "em.find(key)", this is cached, so that repeated lookups don't go to the
> database. If i create a Query referring the  key ("select o from IkbPage o
> where key = ?1"), and then use query.getSingleResult(), it is not cached,
> and I see multiple identical queries.
> 
>  
> 
> Is there a configuration option I need to switch on?
> 
> Or is this just not possible?
> 
>  
> 
> Eirik
> 
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Eclipselink-caching-behaviour-tp18826933p18827678.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.