Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spring.datasource.url=jdbc:sqlserver://<host>:<port>;databaseName=<DB>
- spring.datasource.username=<user>
- spring.datasource.password=<pass>
- spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
- spring.jpa.database-platform=my.project.persistence.CustomSQLServer2012Dialect
- public class PrestigeSQLServer2012Dialect extends SQLServer2012Dialect {
- /**
- * Default constructor
- */
- public PrestigeSQLServer2012Dialect() {
- super();
- registerFunction("convertStringToDate",
- new SQLFunctionTemplate(StandardBasicTypes.DATE, "CONVERT(DATETIME,?1,?2)"));
- // Current SQLServer Date's end of month day (without time)
- registerFunction("endOfCurrentMonth", new SQLFunctionTemplate(StandardBasicTypes.DATE, "EOMONTH(GETDATE())"));
- // Current SQLServer Date's end of month. Add or Remove
- registerFunction("endOfCurrentMonthAdd",
- new SQLFunctionTemplate(StandardBasicTypes.DATE, "EOMONTH(GETDATE(),?1)"));
- // Date's end of month
- registerFunction("endOfMonth", new SQLFunctionTemplate(StandardBasicTypes.DATE, "EOMONTH(?1)"));
- }}
- @Query("select kpi from KPIAccounts kpi where kpi.created between endOfCurrentMonthAdd(:months * -1) and endOfCurrentMonth()")
- Iterable<KPIAccounts> findKPIByMonthRangeBackforward(@Param("months") int months);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement