Skip to content

Commit 6d7a7ca

Browse files
PrimeNG DataTable Lazy and Spring Data Rest (HATEOAS) via Hibernate JPA
1 parent 91554de commit 6d7a7ca

File tree

103 files changed

+8239
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+8239
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-shared-configuration>
3+
<!--
4+
This file contains additional configuration written by modules in the NetBeans IDE.
5+
The configuration is intended to be shared among all the users of project and
6+
therefore it is assumed to be part of version control checkout.
7+
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
8+
-->
9+
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
10+
<!--
11+
Properties that influence various parts of the IDE, especially code formatting and the like.
12+
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
13+
That way multiple projects can share the same settings (useful for formatting rules for example).
14+
Any value defined here will override the pom.xml file value but is only applicable to the current project.
15+
-->
16+
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
17+
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
18+
<org-netbeans-modules-maven-j2ee.netbeans_2e_deploy_2e_on_2e_save>false</org-netbeans-modules-maven-j2ee.netbeans_2e_deploy_2e_on_2e_save>
19+
</properties>
20+
</project-shared-configuration>

8/SHPaginating/pom.xml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>sh</groupId>
6+
<artifactId>SHPaginating</artifactId>
7+
<version>1.0</version>
8+
<packaging>war</packaging>
9+
10+
<name>SHPaginating</name>
11+
12+
<properties>
13+
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
<!-- Java EE 7 -->
19+
<dependency>
20+
<groupId>javax</groupId>
21+
<artifactId>javaee-web-api</artifactId>
22+
<version>7.0</version>
23+
<scope>provided</scope>
24+
</dependency>
25+
<!-- Spring (MVC) -->
26+
<dependency>
27+
<groupId>org.springframework</groupId>
28+
<artifactId>spring-context</artifactId>
29+
<version>4.2.5.RELEASE</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework</groupId>
33+
<artifactId>spring-aop</artifactId>
34+
<version>4.2.5.RELEASE</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework</groupId>
38+
<artifactId>spring-webmvc</artifactId>
39+
<version>4.2.5.RELEASE</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.springframework</groupId>
43+
<artifactId>spring-web</artifactId>
44+
<version>4.2.5.RELEASE</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.springframework</groupId>
48+
<artifactId>spring-orm</artifactId>
49+
<version>4.2.5.RELEASE</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.springframework.data</groupId>
53+
<artifactId>spring-data-rest-webmvc</artifactId>
54+
<version>2.5.2.RELEASE</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.springframework.data</groupId>
58+
<artifactId>spring-data-jpa</artifactId>
59+
<version>1.10.2.RELEASE</version>
60+
</dependency>
61+
<!-- data source proxy -->
62+
<dependency>
63+
<groupId>net.ttddyy</groupId>
64+
<artifactId>datasource-proxy</artifactId>
65+
<version>1.3.3</version>
66+
</dependency>
67+
<!-- Hikari -->
68+
<dependency>
69+
<groupId>com.zaxxer</groupId>
70+
<artifactId>HikariCP</artifactId>
71+
<version>2.4.7</version>
72+
</dependency>
73+
<!-- Hibernate -->
74+
<dependency>
75+
<groupId>org.hibernate</groupId>
76+
<artifactId>hibernate-entitymanager</artifactId>
77+
<version>4.3.11.Final</version>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.hibernate</groupId>
81+
<artifactId>hibernate-core</artifactId>
82+
<version>4.3.11.Final</version>
83+
</dependency>
84+
<!-- Logback -->
85+
<dependency>
86+
<groupId>ch.qos.logback</groupId>
87+
<artifactId>logback-classic</artifactId>
88+
<version>1.1.7</version>
89+
</dependency>
90+
</dependencies>
91+
92+
<build>
93+
<plugins>
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-compiler-plugin</artifactId>
97+
<version>3.1</version>
98+
<configuration>
99+
<source>1.7</source>
100+
<target>1.7</target>
101+
<compilerArguments>
102+
<endorseddirs>${endorsed.dir}</endorseddirs>
103+
</compilerArguments>
104+
</configuration>
105+
</plugin>
106+
<plugin>
107+
<groupId>org.apache.maven.plugins</groupId>
108+
<artifactId>maven-war-plugin</artifactId>
109+
<version>2.3</version>
110+
<configuration>
111+
<failOnMissingWebXml>false</failOnMissingWebXml>
112+
</configuration>
113+
</plugin>
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-dependency-plugin</artifactId>
117+
<version>2.6</version>
118+
<executions>
119+
<execution>
120+
<phase>validate</phase>
121+
<goals>
122+
<goal>copy</goal>
123+
</goals>
124+
<configuration>
125+
<outputDirectory>${endorsed.dir}</outputDirectory>
126+
<silent>true</silent>
127+
<artifactItems>
128+
<artifactItem>
129+
<groupId>javax</groupId>
130+
<artifactId>javaee-endorsed-api</artifactId>
131+
<version>7.0</version>
132+
<type>jar</type>
133+
</artifactItem>
134+
</artifactItems>
135+
</configuration>
136+
</execution>
137+
</executions>
138+
</plugin>
139+
</plugins>
140+
</build>
141+
142+
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package sh.controllers;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.RequestMapping;
5+
import org.springframework.web.bind.annotation.RequestMethod;
6+
7+
@Controller
8+
@RequestMapping("/")
9+
public class IndexController {
10+
11+
@RequestMapping(method = RequestMethod.GET)
12+
public String getIndexPage() {
13+
return "index.jsp";
14+
}
15+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package sh.context;
2+
3+
import javax.servlet.ServletContext;
4+
import javax.servlet.ServletException;
5+
import javax.servlet.ServletRegistration;
6+
import org.springframework.web.WebApplicationInitializer;
7+
import org.springframework.web.context.ContextLoaderListener;
8+
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
9+
import org.springframework.web.servlet.DispatcherServlet;
10+
import sh.simpleconfiguration.SHConfiguration;
11+
12+
/**
13+
*
14+
* @author Anghel Leonard
15+
*/
16+
public class WAC implements WebApplicationInitializer {
17+
18+
@Override
19+
public void onStartup(ServletContext container) throws ServletException {
20+
21+
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
22+
ctx.register(SHConfiguration.class);
23+
container.addListener(new ContextLoaderListener(ctx));
24+
ctx.setServletContext(container);
25+
26+
ServletRegistration.Dynamic servlet_dispatcher = container.addServlet("dispatcher", new DispatcherServlet(ctx));
27+
ServletRegistration.Dynamic servlet_rest = container.addServlet("rest-exporter", new DispatcherServlet(ctx));
28+
29+
servlet_dispatcher.setLoadOnStartup(1);
30+
servlet_rest.setLoadOnStartup(2);
31+
servlet_rest.addMapping("/items/");
32+
servlet_dispatcher.addMapping("/");
33+
}
34+
35+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package sh.dao;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.data.repository.query.Param;
5+
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
6+
import sh.model.Product;
7+
8+
/**
9+
*
10+
* @author Anghel Leonard
11+
*/
12+
@RepositoryRestResource(collectionResourceRel = "items", path = "items")
13+
public interface ProductRepository extends JpaRepository<Product, Long> {
14+
15+
// not used!
16+
Product findByName(@Param("name") String name);
17+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package sh.model;
2+
3+
import java.io.Serializable;
4+
import java.util.Objects;
5+
import javax.persistence.Basic;
6+
import javax.persistence.Column;
7+
import javax.persistence.Entity;
8+
import javax.persistence.GeneratedValue;
9+
import javax.persistence.GenerationType;
10+
import javax.persistence.Id;
11+
import javax.persistence.Table;
12+
import javax.validation.constraints.Size;
13+
import javax.xml.bind.annotation.XmlRootElement;
14+
15+
/**
16+
*
17+
* @author Anghel Leonard
18+
*/
19+
@Entity
20+
@Table(name = "product")
21+
@XmlRootElement
22+
public class Product implements Serializable {
23+
24+
private static final long serialVersionUID = 1L;
25+
@Id
26+
@GeneratedValue(strategy = GenerationType.AUTO)
27+
@Basic(optional = false)
28+
@Column(name = "id")
29+
private Long id;
30+
@Size(max = 50)
31+
@Column(name = "name")
32+
private String name;
33+
@Size(max = 50)
34+
@Column(name = "code")
35+
private String code;
36+
37+
public Product() {
38+
}
39+
40+
public Product(Long id) {
41+
this.id = id;
42+
}
43+
44+
public Long getId() {
45+
return id;
46+
}
47+
48+
public void setId(Long id) {
49+
this.id = id;
50+
}
51+
52+
public String getName() {
53+
return name;
54+
}
55+
56+
public void setName(String name) {
57+
this.name = name;
58+
}
59+
60+
public String getCode() {
61+
return code;
62+
}
63+
64+
public void setCode(String code) {
65+
this.code = code;
66+
}
67+
68+
@Override
69+
public int hashCode() {
70+
int hash = 7;
71+
hash = 71 * hash + Objects.hashCode(this.id);
72+
hash = 71 * hash + Objects.hashCode(this.name);
73+
hash = 71 * hash + Objects.hashCode(this.code);
74+
return hash;
75+
}
76+
77+
@Override
78+
public boolean equals(Object obj) {
79+
if (this == obj) {
80+
return true;
81+
}
82+
if (obj == null) {
83+
return false;
84+
}
85+
if (getClass() != obj.getClass()) {
86+
return false;
87+
}
88+
final Product other = (Product) obj;
89+
if (!Objects.equals(this.name, other.name)) {
90+
return false;
91+
}
92+
if (!Objects.equals(this.code, other.code)) {
93+
return false;
94+
}
95+
if (!Objects.equals(this.id, other.id)) {
96+
return false;
97+
}
98+
return true;
99+
}
100+
101+
@Override
102+
public String toString() {
103+
return "Product{" + "id=" + id + ", name=" + name + ", code=" + code + '}';
104+
}
105+
106+
}

0 commit comments

Comments
 (0)