Skip to content

Instantly share code, notes, and snippets.

@johndemic
johndemic / gist:3841064
Created October 5, 2012 17:11
Directory Implementation with Mule and Cassandra
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:cassandradb="http://www.mulesoft.org/schema/mule/cassandradb" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cassandradb http://www.mulesoft.org/schema/mule/cassandradb/3.2/mule-cassandradb.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/sch
@johndemic
johndemic / gist:3286689
Created August 7, 2012 16:04
Component Participating in JPA Flow
<flow name="dogGroomingFlow">
<vm:inbound-endpoint path="dog.groom.in"/>
<transactional>
<jpa:merge/>
<component class="service.DogServiceImpl"/>
</transactional>
<vm:outbound-endpoint path="dog.groom.out"/>
</flow>
public class DogServiceImpl {
@PersistenceContext
EntityManager entityManager;
public Dog groom(Dog dog) {
return entityManager.merge(dog);
}
}
@johndemic
johndemic / gist:3286620
Created August 7, 2012 15:57
JPA Detach
<flow name="testDetach">
<transactional>
<jpa:detach/>
</transactional>
</flow>
@johndemic
johndemic / gist:3286613
Created August 7, 2012 15:56
JPA Merge
<flow name="testMerge">
<vm:inbound-endpoint path="in"/>
<transactional>
<jpa:merge/>
....other processing here....
</transactional>
<vm:outbound-endpoint path="foo"/>
</flow>
@johndemic
johndemic / gist:3286592
Created August 7, 2012 15:54
JPA Persist and Query
<flow name="testTransactionalInsertAndQuery">
<transactional>
<jpa:persist/>
<jpa:query statement="from Dog dog where dog.name = 'Cujo'"/>
</transactional>
</flow>
@johndemic
johndemic / gist:3286544
Created August 7, 2012 15:49
Find a JPA Entity by its ID
<flow name="testFind">
<jpa:find entityClass="domain.Dog" id-ref="#[payload:]"/>
</flow>
@johndemic
johndemic / gist:3285898
Created August 7, 2012 14:39
Criteria Queries with the JPA Module
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Dog> criteriaQuery = criteriaBuilder.createQuery(Dog.class);
Root<Dog> from = criteriaQuery.from(Dog.class);
Predicate condition = criteriaBuilder.equal(from.get("name"), "Cujo");
criteriaQuery.where(condition);
runFlowWithPayloadAndExpect("testQuery", expectedResults, criteriaQuery);
@johndemic
johndemic / gist:3285880
Created August 7, 2012 14:35
JPA Query with Map Parameters
<flow name="testQueryWithMapParameters">
<jpa:query statement="from Dog dog where dog.name = :name and dog.breed = :breed" queryParameters-ref="#[payload:]"/>
</flow>
@johndemic
johndemic / gist:3285863
Created August 7, 2012 14:32
JPA Query
<flow name="testQueryWithListParameters">
<jpa:query statement="from Dog dog where dog.name = ?" queryParameters-ref="#[payload:]"/>
<vm:outbound-endpoint path="foo"/>
</flow>