Skip to content

Instantly share code, notes, and snippets.

@baxtheman
baxtheman / TestNativeQueryToListJson.java
Created October 20, 2017 14:25
Java JPA Native Query using Tuple and return List of Jackson JSON Object
/*
Needs Hibernate 5.2.11.Final
*/
public List<ObjectNode> getQuery(
Integer anno,
Integer settimana) {
Query q = em.createNativeQuery(
"NATIVE SQL....",Tuple.class);
@mtrbean
mtrbean / mysql_date_trunc
Last active February 2, 2021 21:18
MySQL date_trunc equivalent
DATE_TRUNC('week', now()) === STR_TO_DATE(CONCAT(YEARWEEK(now(), 2), ' Sunday'), '%X%V %W')
DATE_TRUNC('month', now()) === DATE_FORMAT(now(), '%Y-%m-01')