Skip to content

Instantly share code, notes, and snippets.

@pblanchardie
pblanchardie / SqlFunctionsMetadataBuilderContributor.java
Created November 20, 2020 20:23
PostgreSQL ILIKE with JPA Criteria API and Hibernate
import org.hibernate.boot.MetadataBuilder;
import org.hibernate.boot.spi.MetadataBuilderContributor;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.type.StandardBasicTypes;
/**
* Enable with Spring Boot:
* spring:
* jpa:
* properties:
<!-- DataNucleus JPA Persistence Provider -->
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<properties>
<!-- TODO property -->
<property name="datanucleus.ConnectionURL" value="mongodb:/biorelay"/>
<property name="datanucleus.storeManagerType" value="mongodb"/>
<property name="datanucleus.autoCreateSchema" value="true"/>
<property name="datanucleus.validateTables" value="false"/>
</properties>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"
@pblanchardie
pblanchardie / geocodingResults.js
Created February 19, 2013 12:52
Get Google's geocoding results
for (i = 0; i < results[r].address_components.length; i++) {
var type = results[r].address_components[i].types[0];
if (type == 'locality') {
$option.attr("value", r);
formatted[r].city = results[r].address_components[i].long_name;
} else if (type == 'route') {
$option.attr("value", r);
formatted[r].street = results[r].address_components[i].long_name;
} else if (type == 'postal_code') {
$option.attr("value", r);