Skip to content

Instantly share code, notes, and snippets.

@asicfr
asicfr / struts.xml
Created October 8, 2012 14:32
struts2RestJpaBootstrap - struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="false" />
<constant name="struts.ui.theme" value="html5bootstrap" />
<constant name="struts.custom.i18n.resources" value="global" /><!-- fichier properties global a toute l'application : global.properties -->
@asicfr
asicfr / tree
Created October 8, 2012 14:38
struts2RestJpaBootstrap - structure du projet
+---src
+---main
+---java
+---resources
+---webapp
+---css
+---img
+---javascript
+---WEB-INF
@asicfr
asicfr / pom.xml
Created October 8, 2012 14:56
struts2RestJpaBootstrap - pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tutorial</groupId>
<artifactId>struts2RestJpaBootstrap</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>struts2RestJpaBootstrap</name>
@asicfr
asicfr / persistence.xml
Created October 8, 2012 15:08
struts2RestJpaBootstrap - persistence
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="jpaderby" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.demo.vo.bean.Book</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
<property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="hibernate.connection.url" value="jdbc:derby://localhost:1527/bookstore"/>
@asicfr
asicfr / tree2
Created October 8, 2012 15:17
struts2RestJpaBootstrap - structure du projet avec boostrap twitter
+---src
+---main
+---java
+---resources
¦ +---META-INF
¦ +---template
¦ +---html5bootstrap
+---webapp
+---css
+---bootstrap-responsive.min.css
@asicfr
asicfr / web.xml
Created October 8, 2012 15:24
struts2RestJpaBootstrap - web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>test1-struts2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
@asicfr
asicfr / Book.java
Created October 15, 2012 08:47
struts2RestJpaBootstrap - vo
package org.demo.vo.bean;
import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.* ;
import org.hibernate.validator.constraints.* ;
@asicfr
asicfr / JpaBookDAO.java
Created October 15, 2012 08:49
struts2RestJpaBootstrap - dao
package org.demo.vo.dao;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
@asicfr
asicfr / GenericJpaDao.java
Created October 15, 2012 08:51
struts2RestJpaBootstrap - dao generic
package org.demo.util;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
@asicfr
asicfr / EntityManagerHelper.java
Created October 15, 2012 08:53
struts2RestJpaBootstrap - persistence manager
package org.demo.util;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class EntityManagerHelper {
private static final String JPA_TEST = "jpaderby";
private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory(JPA_TEST);