File tree Expand file tree Collapse file tree
main/java/io/ebean/datasource
test/java/io/ebean/datasource Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -485,14 +485,23 @@ default DataSourceBuilder leakTimeMinutes(int leakTimeMinutes) {
485485 /**
486486 * Set the size of the PreparedStatement cache (per connection).
487487 * <p>
488- * Defaults to 100 .
488+ * Defaults to 300 .
489489 */
490490 default DataSourceBuilder pstmtCacheSize (int pstmtCacheSize ) {
491491 return setPstmtCacheSize (pstmtCacheSize );
492492 }
493493
494494 /**
495- * @deprecated - migrate to {@link #pstmtCacheSize(int)}.
495+ * Set the size of the PreparedStatement cache (per connection).
496+ * <p>
497+ * Defaults to 300.
498+ */
499+ default DataSourceBuilder preparedStatementCacheSize (int pstmtCacheSize ) {
500+ return setPstmtCacheSize (pstmtCacheSize );
501+ }
502+
503+ /**
504+ * @deprecated - migrate to {@link #preparedStatementCacheSize(int)}.
496505 */
497506 @ Deprecated
498507 DataSourceBuilder setPstmtCacheSize (int pstmtCacheSize );
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ public class DataSourceConfig implements DataSourceBuilder.Settings {
7474 private int maxInactiveTimeSecs = 300 ;
7575 private int maxAgeMinutes = 0 ;
7676 private int trimPoolFreqSecs = 59 ;
77- private int pstmtCacheSize = 100 ;
77+ private int pstmtCacheSize = 300 ;
7878 private int cstmtCacheSize = 20 ;
7979 private int waitTimeoutMillis = 1000 ;
8080 private String poolListener ;
Original file line number Diff line number Diff line change @@ -353,6 +353,39 @@ public void from_noPrefix() throws IOException {
353353 assertConfigValues (builder2 .settings ());
354354 }
355355
356+ @ Test
357+ void pstmtCacheSize_default_expect_300 () {
358+ DataSourceConfig config = new DataSourceConfig ();
359+ assertThat (config .getPstmtCacheSize ()).isEqualTo (300 );
360+ }
361+
362+ @ Test
363+ void pstmtCacheSize_explicit_setValue () {
364+ DataSourceConfig config = new DataSourceConfig ();
365+ config .setPstmtCacheSize (500 );
366+ assertThat (config .getPstmtCacheSize ()).isEqualTo (500 );
367+ }
368+
369+ @ Test
370+ void pstmtCacheSize_builder_method () {
371+ var builder = DataSourceBuilder .create ()
372+ .pstmtCacheSize (250 );
373+ assertThat (builder .settings ().getPstmtCacheSize ()).isEqualTo (250 );
374+ }
375+
376+ @ Test
377+ void preparedStatementCacheSize_builder_method () {
378+ var builder = DataSourceBuilder .create ()
379+ .preparedStatementCacheSize (400 );
380+ assertThat (builder .settings ().getPstmtCacheSize ()).isEqualTo (400 );
381+ }
382+
383+ @ Test
384+ void preparedStatementCacheSize_builder_default () {
385+ var builder = DataSourceBuilder .create ();
386+ assertThat (builder .settings ().getPstmtCacheSize ()).isEqualTo (300 );
387+ }
388+
356389 private static void assertConfigValues (DataSourceBuilder .Settings config ) {
357390 assertThat (config .getReadOnlyUrl ()).isEqualTo ("myReadOnlyUrl" );
358391 assertThat (config .getUrl ()).isEqualTo ("myUrl" );
You can’t perform that action at this time.
0 commit comments