@@ -41,14 +41,15 @@ private void initializeCache() {
41
41
Configuration cacheManagerConfig = new Configuration ();
42
42
43
43
// ***To Cluster With Terracotta***
44
- // add the ehcache-terracotta-ee jar to your class path and uncomment the
44
+ // add the ehcache-terracotta-ee jar to your class path and uncomment
45
+ // the
45
46
// code in the "To Cluster With Terracotta" sections
46
47
//
47
48
// TerracottaClientConfiguration tcConfig = new
48
49
// TerracottaClientConfiguration()
49
50
// .url("localhost:9510");
50
51
// cacheManagerConfig.addTerracottaConfig(tcConfig);
51
-
52
+
52
53
// ***To Cluster With Terracotta***
53
54
54
55
cacheManagerConfig .addDefaultCache (new CacheConfiguration ());
@@ -76,7 +77,7 @@ private void initializeCache() {
76
77
searchable .addSearchAttribute (new SearchAttribute ().name ("state" )
77
78
.expression ("value.getAddress().getState()" ));
78
79
79
- // Coding your own extracter
80
+ // Coding your own extractor
80
81
searchable .addSearchAttribute (new SearchAttribute ().name ("name" )
81
82
.className (NameAttributeExtractor .class .getName ()));
82
83
@@ -105,9 +106,10 @@ public void runTests() throws IOException {
105
106
Attribute <Gender > gender = cache .getSearchAttribute ("gender" );
106
107
Attribute <String > name = cache .getSearchAttribute ("name" );
107
108
Attribute <String > state = cache .getSearchAttribute ("state" );
108
-
109
+
109
110
Query query = cache .createQuery ();
110
111
query .includeKeys ();
112
+ query .includeValues ();
111
113
query .addCriteria (name .ilike ("Ari*" ).and (gender .eq (Gender .MALE )))
112
114
.addOrderBy (age , Direction .ASCENDING ).maxResults (10 );
113
115
@@ -120,11 +122,9 @@ public void runTests() throws IOException {
120
122
+ " Size: " + results .size ());
121
123
System .out .println ("----Results-----\n " );
122
124
for (Result result : results .all ()) {
123
- System .out
124
- .println ("Got: Key[" + result .getKey () + "] Value class ["
125
- + cache .get (result .getKey ()).getValue ()
126
- + "] Value ["
127
- + cache .get (result .getKey ()).getValue () + "]" );
125
+ System .out .println ("Got: Key[" + result .getKey ()
126
+ + "] Value class [" + result .getValue ().getClass ()
127
+ + "] Value [" + result .getValue () + "]" );
128
128
}
129
129
130
130
read ();
@@ -149,7 +149,8 @@ public void runTests() throws IOException {
149
149
Query averageAgeQuery = cache .createQuery ();
150
150
averageAgeQuery .includeAggregator (Aggregators .average (age ));
151
151
System .out .println ("Average age: "
152
- + averageAgeQuery .execute ().all ().iterator ().next ().getAggregatorResults ());
152
+ + averageAgeQuery .execute ().all ().iterator ().next ()
153
+ .getAggregatorResults ());
153
154
154
155
read ();
155
156
@@ -160,7 +161,8 @@ public void runTests() throws IOException {
160
161
agesBetween .addCriteria (age .between (30 , 40 ));
161
162
agesBetween .includeAggregator (Aggregators .average (age ));
162
163
System .out .println ("Average age between 30 and 40: "
163
- + agesBetween .execute ().all ().iterator ().next ().getAggregatorResults ());
164
+ + agesBetween .execute ().all ().iterator ().next ()
165
+ .getAggregatorResults ());
164
166
165
167
read ();
166
168
@@ -170,7 +172,8 @@ public void runTests() throws IOException {
170
172
state .eq ("NJ" ));
171
173
newJerseyCountQuery .includeAggregator (Aggregators .count ());
172
174
System .out .println ("Count of people from NJ: "
173
- + newJerseyCountQuery .execute ().all ().iterator ().next ().getAggregatorResults ());
175
+ + newJerseyCountQuery .execute ().all ().iterator ().next ()
176
+ .getAggregatorResults ());
174
177
}
175
178
176
179
private void loadCache () {
0 commit comments