Skip to content

Instantly share code, notes, and snippets.

@jhiemer
jhiemer / fetch.java
Created April 26, 2012 08:24
Fetch Impl for relation
public void fetch(String association, Object entity) {
if(association == null || entity == null){
return;
}
String hql = Utils.appendAll("SELECT n.", association, " FROM ", entity.getClass().getSimpleName(), " n WHERE n.id = :id").toString();
Query query = em.createQuery(hql);
try {
Object id = PropertyUtils.getProperty(entity, "id");
query.setParameter("id", id);
List<?> result = query.getResultList();
@jhiemer
jhiemer / application-model.xml
Created May 2, 2012 05:26
Application model file of subproject
<context:property-placeholder location="classpath:application-model.properties" />
<jpa:repositories base-package="com.model.dao" />
<context:annotation-config />
<context:component-scan base-package="com.model" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${database.driver}" p:url="${database.url}"
/**
* Either the user's pre-configured {@link ConversionService} or the
* {@link DefaultConversionService}.
*
* @return
*/
@Bean
ConversionService conversionService() {
if (null != customConversionService) {
@Autowired(required = false)
RestConversionService customConversionService = new RestConversionService();
/**
* Either the user's pre-configured {@link ConversionService} or the
* {@link DefaultConversionService}.
*
* @return
*/
@Bean
<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<ref bean="jsonConverter" />
<ref bean="stringConverter" />
</list>
</property>
</bean>
<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ evoila-rest ---
[INFO] de.rest:rest:war:1.0-SNAPSHOT
[INFO] +- org.springframework.data:spring-data-rest-webmvc:jar:1.0.0.BUILD-SNAPSHOT:compile
[INFO] | +- org.springframework.data:spring-data-rest-repository:jar:1.0.0.BUILD-SNAPSHOT:compile
[INFO] | | \- org.springframework.data:spring-data-rest-core:jar:1.0.0.BUILD-SNAPSHOT:compile
[INFO] | | \- com.google.guava:guava:jar:12.0:compile
[INFO] | | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | +- ch.qos.logback:logback-classic:jar:1.0.6:runtime
[INFO] | | \- ch.qos.logback:logback-core:jar:1.0.6:runtime
[INFO] | +- javax.validation:validation-api:jar:1.0.0.GA:compile
Hibernate: select sla0_."Id" as Id1_23_0_, sla0_."Description" as Descript2_23_0_, sla0_."Name" as Name3_23_0_, sla0_."Enabled" as Enabled4_23_0_, sla0_."Price" as Price5_23_0_, sla0_."Provider_id" as Provider6_23_0_, sla0_."SLALevel_id" as SLALevel7_23_0_ from "Sla" sla0_ where sla0_."Id"=?
Handler<Object, ResponseEntity<?>> entityHandler = new Handler<Object, ResponseEntity<?>>() {
@Override public ResponseEntity<?> handle(Object linkedEntity) {
if(attrMeta.isCollectionLike()) {
Collection c = new ArrayList();
Collection current = attrMeta.asCollection(entity);
if(request.getMethod() == HttpMethod.POST && null != current) {
c.addAll(current);
}
c.add(linkedEntity);
{
links: [
{
rel: "sla.search",
href: "http://localhost:8080/rest/sla/search"
}
],
content: [
{
links: [