Skip to content

Instantly share code, notes, and snippets.

@asicfr
asicfr / struts.xml
Created Oct 8, 2012
struts2RestJpaBootstrap - struts.xml
View 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 Oct 8, 2012
struts2RestJpaBootstrap - structure du projet
View tree
+---src
+---main
+---java
+---resources
+---webapp
+---css
+---img
+---javascript
+---WEB-INF
@asicfr
asicfr / pom.xml
Created Oct 8, 2012
struts2RestJpaBootstrap - pom.xml
View 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 Oct 8, 2012
struts2RestJpaBootstrap - persistence
View persistence.xml
<?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 Oct 8, 2012
struts2RestJpaBootstrap - structure du projet avec boostrap twitter
View tree2
+---src
+---main
+---java
+---resources
¦ +---META-INF
¦ +---template
¦ +---html5bootstrap
+---webapp
+---css
+---bootstrap-responsive.min.css
@asicfr
asicfr / web.xml
Created Oct 8, 2012
struts2RestJpaBootstrap - web.xml
View 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 Oct 15, 2012
struts2RestJpaBootstrap - vo
View Book.java
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 Oct 15, 2012
struts2RestJpaBootstrap - dao
View JpaBookDAO.java
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 Oct 15, 2012
struts2RestJpaBootstrap - dao generic
View GenericJpaDao.java
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 Oct 15, 2012
struts2RestJpaBootstrap - persistence manager
View EntityManagerHelper.java
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);
You can’t perform that action at this time.