Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Commit 01b7a46

Browse files
committed
Envers functionality added in Server modules
1 parent 057f107 commit 01b7a46

File tree

24 files changed

+19287
-252
lines changed

24 files changed

+19287
-252
lines changed

.idea/dataSources.ids

Lines changed: 18564 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dataSources.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Maven__org_hibernate_hibernate_envers_4_1_2_Final.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 285 additions & 232 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ A sample project for exemplifying and testing various JEE technologies - mainly
44

55
## Contents
66

7-
The project consists of serveral sub-projects or modules grouped by name as follows...
7+
The project consists of several sub-projects or modules grouped by name as follows...
88

99
- sample-jee-client-*
1010
- sample-jee-relay-*
1111
- sample-jee-server-*
1212
- sample-jee-standalone-*
1313

14-
The *client* modules contins various server-based client components (EJBs, Servlets etc) that calls other server components
15-
in the *relay* or *server* moules.
14+
The *client* modules contains various server-based client components (EJBs, Servlets etc) that calls other server components
15+
in the *relay* or *server* modules.
1616

1717
The *relay* modules act as intermediaries, accepting calls from some client and sending it on to some component in the
1818
*server* modules.
1919

2020
The *server* modules accept calls from some client.
2121

22-
The *standalone* modules normally act as Java standlone clients - in counterpart to the ones in the *client* modules
22+
The *standalone* modules normally act as Java standalone clients - in counterpart to the ones in the *client* modules
2323
that normally are server-based components acting as clients.
2424

2525
### sample-jee-client-*
@@ -50,7 +50,7 @@ and/or sample-jee-server-*.
5050

5151
### sample-jee-relay-*
5252

53-
Three moudules (ear, ejb, ejb-remote)
53+
Three modules (ear, ejb, ejb-remote)
5454

5555
#### sample-jee-relay-ear
5656

sample-jee-server-domain/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
<name>${project.parent.artifactId} Server Domain Model JAR</name>
1717

1818
<dependencies>
19+
<!-- hibernate envers -->
20+
<dependency>
21+
<groupId>org.hibernate</groupId>
22+
<artifactId>hibernate-envers</artifactId>
23+
<scope>provided</scope>
24+
</dependency>
1925
<!-- jpa -->
2026
<dependency>
2127
<groupId>org.hibernate.javax.persistence</groupId>

sample-jee-server-domain/sample-jee-server-domain.iml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
</content>
2323
<orderEntry type="inheritedJdk" />
2424
<orderEntry type="sourceFolder" forTests="false" />
25+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate:hibernate-envers:4.1.2.Final" level="project" />
26+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.logging:jboss-logging:3.1.1.GA" level="project" />
27+
<orderEntry type="library" scope="PROVIDED" name="Maven: dom4j:dom4j:1.6.1" level="project" />
28+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.1.Final" level="project" />
2529
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final" level="project" />
2630
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.validation:validation-api:1.0.0.GA" level="project" />
2731
</component>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.swesource.sample.jee.domain;
2+
3+
import org.hibernate.envers.Audited;
4+
5+
import javax.persistence.Column;
6+
import javax.persistence.Entity;
7+
import javax.persistence.GeneratedValue;
8+
import javax.persistence.Id;
9+
import javax.persistence.Temporal;
10+
import javax.persistence.TemporalType;
11+
import javax.validation.constraints.Digits;
12+
import javax.validation.constraints.Size;
13+
import java.io.Serializable;
14+
import java.util.Date;
15+
16+
/**
17+
* @author arnie
18+
*/
19+
@Entity
20+
@Audited
21+
public class Address implements Serializable {
22+
23+
private static final long serialVersionUID = 1L;
24+
private static final int ZIP_LENGTH = 5;
25+
private static final int COUNTRY_MAX = 2;
26+
private static final int COUNTRY_MIN = 2;
27+
28+
@Id
29+
@GeneratedValue
30+
private Long id;
31+
32+
private String street;
33+
34+
private String city;
35+
36+
@Column(length = ZIP_LENGTH)
37+
@Digits(integer = ZIP_LENGTH, fraction = 0)
38+
private String zip;
39+
40+
/* ISO 3166 A2 compliant country code */
41+
@Column(length = COUNTRY_MAX)
42+
@Size(min = COUNTRY_MIN, max = COUNTRY_MAX)
43+
private String country;
44+
45+
@Temporal(value = TemporalType.DATE)
46+
private Date movingInDate;
47+
48+
@Override
49+
public String toString() {
50+
return this.getClass().getName() + "@" + hashCode() + " [id = " + id + "]";
51+
}
52+
53+
public Long getId() {
54+
return id;
55+
}
56+
57+
public void setId(Long id) {
58+
this.id = id;
59+
}
60+
61+
public String getStreet() {
62+
return street;
63+
}
64+
65+
public void setStreet(String street) {
66+
this.street = street;
67+
}
68+
69+
public String getCity() {
70+
return city;
71+
}
72+
73+
public void setCity(String city) {
74+
this.city = city;
75+
}
76+
77+
public String getZip() {
78+
return zip;
79+
}
80+
81+
public void setZip(String zip) {
82+
this.zip = zip;
83+
}
84+
85+
public String getCountry() {
86+
return country;
87+
}
88+
89+
public void setCountry(String country) {
90+
this.country = country;
91+
}
92+
93+
public Date getMovingInDate() {
94+
return movingInDate;
95+
}
96+
97+
public void setMovingInDate(Date movingInDate) {
98+
this.movingInDate = movingInDate;
99+
}
100+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.swesource.sample.jee.domain;
2+
3+
import org.hibernate.envers.Audited;
4+
5+
import javax.persistence.CascadeType;
6+
import javax.persistence.Entity;
7+
import javax.persistence.GeneratedValue;
8+
import javax.persistence.Id;
9+
import javax.persistence.NamedQueries;
10+
import javax.persistence.NamedQuery;
11+
import javax.persistence.OneToMany;
12+
import java.io.Serializable;
13+
import java.util.Collection;
14+
15+
/**
16+
* @author arnie
17+
*/
18+
@Entity
19+
@Audited(withModifiedFlag = true)
20+
@NamedQueries(value =
21+
@NamedQuery(name = "findPersonVersionsById", query = "select p from Person p where p.id = :id")
22+
)
23+
public class Person implements Serializable {
24+
25+
private static final long serialVersionUID = 1L;
26+
27+
@Id
28+
@GeneratedValue
29+
private Long id;
30+
31+
private String firstName;
32+
33+
private String lastName;
34+
35+
@OneToMany(cascade = CascadeType.ALL)
36+
private Collection<Address> addresses;
37+
38+
@Override
39+
public String toString() {
40+
return this.getClass().getName() + "@" + hashCode() + " [id = " + id + "]";
41+
}
42+
43+
public Long getId() {
44+
return id;
45+
}
46+
47+
public void setId(Long id) {
48+
this.id = id;
49+
}
50+
51+
public String getFirstName() {
52+
return firstName;
53+
}
54+
55+
public void setFirstName(String firstName) {
56+
this.firstName = firstName;
57+
}
58+
59+
public String getLastName() {
60+
return lastName;
61+
}
62+
63+
public void setLastName(String lastName) {
64+
this.lastName = lastName;
65+
}
66+
67+
public Collection<Address> getAddresses() {
68+
return addresses;
69+
}
70+
71+
public void setAddresses(Collection<Address> addresses) {
72+
this.addresses = addresses;
73+
}
74+
}

sample-jee-server-domain/src/main/java/com/swesource/sample/jee/domain/User.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class User implements Serializable {
2323
private Long id;
2424

2525
@Column(unique = true, nullable = false, length = USERNAME_MAX)
26+
//@Column(nullable = false, length = USERNAME_MAX)
2627
@NotNull
2728
@Size(min = USERNAME_MIN, max = USERNAME_MAX)
2829
private String username;
@@ -45,6 +46,6 @@ public void setUsername(String username) {
4546

4647
@Override
4748
public String toString() {
48-
return "User@" + hashCode() + " [id = " + id + "]";
49+
return this.getClass().getName() + "@" + hashCode() + " [id = " + id + "]";
4950
}
5051
}

0 commit comments

Comments
 (0)