Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. spring.datasource.url=jdbc:sqlserver://<host>:<port>;databaseName=<DB>
  2. spring.datasource.username=<user>
  3. spring.datasource.password=<pass>
  4. spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
  5. spring.jpa.database-platform=my.project.persistence.CustomSQLServer2012Dialect
  6.  
  7. public class PrestigeSQLServer2012Dialect extends SQLServer2012Dialect {
  8.  
  9. /**
  10. * Default constructor
  11. */
  12. public PrestigeSQLServer2012Dialect() {
  13. super();
  14. registerFunction("convertStringToDate",
  15. new SQLFunctionTemplate(StandardBasicTypes.DATE, "CONVERT(DATETIME,?1,?2)"));
  16.  
  17. // Current SQLServer Date's end of month day (without time)
  18. registerFunction("endOfCurrentMonth", new SQLFunctionTemplate(StandardBasicTypes.DATE, "EOMONTH(GETDATE())"));
  19.  
  20. // Current SQLServer Date's end of month. Add or Remove
  21. registerFunction("endOfCurrentMonthAdd",
  22. new SQLFunctionTemplate(StandardBasicTypes.DATE, "EOMONTH(GETDATE(),?1)"));
  23.  
  24. // Date's end of month
  25. registerFunction("endOfMonth", new SQLFunctionTemplate(StandardBasicTypes.DATE, "EOMONTH(?1)"));
  26.  
  27. }}
  28.  
  29. @Query("select kpi from KPIAccounts kpi where kpi.created between endOfCurrentMonthAdd(:months * -1) and endOfCurrentMonth()")
  30. Iterable<KPIAccounts> findKPIByMonthRangeBackforward(@Param("months") int months);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement