Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of Spring JPA repository abstraction.
Port of the Hades project whereas the JPA independent part resides in Spring Data Commons Core. Reflect changes refactorings for DATACMNS-2, DATACMNS-3, DATACMNS-4, DATACMNS-5, DATACMNS-6, DATACMNS-8, DATACMNS-9, DATAJPA-2.
- Loading branch information
Showing
109 changed files
with
9,957 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target/ | ||
.settings/ | ||
.project | ||
.classpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
<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> | ||
<artifactId>spring-data-jpa</artifactId> | ||
<name>Spring JPA</name> | ||
|
||
<parent> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-commons-parent</artifactId> | ||
<version>1.0.0.BUILD-SNAPSHOT</version> | ||
<relativePath>../spring-data-commons-parent/pom.xml</relativePath> | ||
</parent> | ||
|
||
<properties> | ||
<hibernate.version>3.6.0.Final</hibernate.version> | ||
<openjpa.version>2.0.0</openjpa.version> | ||
<aspectj.version>1.6.8</aspectj.version> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>spring-data-commons-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-orm</artifactId> | ||
<version>${org.springframework.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjrt</artifactId> | ||
<version>${aspectj.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjtools</artifactId> | ||
<version>${aspectj.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-aspects</artifactId> | ||
<version>${org.springframework.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-test</artifactId> | ||
<version>${org.springframework.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-all</artifactId> | ||
<version>1.8.4</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.hsqldb</groupId> | ||
<artifactId>com.springsource.org.hsqldb</artifactId> | ||
<version>1.8.0.10</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>1.6</version> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
|
||
<!-- Persistence providers --> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-entitymanager</artifactId> | ||
<version>${hibernate.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>com.springsource.org.eclipse.persistence.jpa</artifactId> | ||
<version>2.0.0</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.openjpa</groupId> | ||
<artifactId>openjpa-persistence-jdbc</artifactId> | ||
<version>${openjpa.version}</version> | ||
<optional>true</optional> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<argLine>-javaagent:${settings.localRepository}/org/springframework/org.springframework.instrument/${org.springframework.version}/org.springframework.instrument-${org.springframework.version}.jar -javaagent:${settings.localRepository}/org/apache/openjpa/openjpa/${openjpa.version}/openjpa-${openjpa.version}.jar</argLine> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>org.springframework.instrument</artifactId> | ||
<version>${org.springframework.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.openjpa</groupId> | ||
<artifactId>openjpa</artifactId> | ||
<version>${openjpa.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
<!-- | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>aspectj-maven-plugin</artifactId> | ||
<version>1.3</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjrt</artifactId> | ||
<version>${aspectj.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjtools</artifactId> | ||
<version>${aspectj.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<verbose>true</verbose> | ||
<aspectLibraries> | ||
<aspectLibrary> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-aspects</artifactId> | ||
</aspectLibrary> | ||
</aspectLibraries> | ||
<includes> | ||
<include>**/auditing/support/*.java</include> | ||
</includes> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
</configuration> | ||
</plugin>--> | ||
</plugins> | ||
|
||
</build> | ||
</project> |
152 changes: 152 additions & 0 deletions
152
src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/* | ||
* Copyright 2008-2010 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package org.springframework.data.jpa.domain; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
import javax.persistence.MappedSuperclass; | ||
import javax.persistence.OneToOne; | ||
import javax.persistence.Temporal; | ||
import javax.persistence.TemporalType; | ||
|
||
import org.joda.time.DateTime; | ||
import org.springframework.data.domain.Auditable; | ||
|
||
|
||
/** | ||
* Abstract base class for auditable entities. Stores the audition values in | ||
* persistent fields. | ||
* | ||
* @author Oliver Gierke | ||
* @param <U> the auditing type. Typically some kind of user. | ||
* @param <PK> the type of the auditing type's idenifier | ||
*/ | ||
@MappedSuperclass | ||
public abstract class AbstractAuditable<U, PK extends Serializable> extends | ||
AbstractPersistable<PK> implements Auditable<U, PK> { | ||
|
||
private static final long serialVersionUID = 141481953116476081L; | ||
|
||
@OneToOne | ||
private U createdBy; | ||
|
||
@Temporal(TemporalType.TIMESTAMP) | ||
private Date createdDate; | ||
|
||
@OneToOne | ||
private U lastModifiedBy; | ||
|
||
@Temporal(TemporalType.TIMESTAMP) | ||
private Date lastModifiedDate; | ||
|
||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see org.synyx.hades.domain.auditing.Auditable#getCreatedBy() | ||
*/ | ||
public U getCreatedBy() { | ||
|
||
return createdBy; | ||
} | ||
|
||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see | ||
* org.synyx.hades.domain.auditing.Auditable#setCreatedBy(java.lang.Object) | ||
*/ | ||
public void setCreatedBy(final U createdBy) { | ||
|
||
this.createdBy = createdBy; | ||
} | ||
|
||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see org.synyx.hades.domain.auditing.Auditable#getCreatedDate() | ||
*/ | ||
public DateTime getCreatedDate() { | ||
|
||
return null == createdDate ? null : new DateTime(createdDate); | ||
} | ||
|
||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see | ||
* org.synyx.hades.domain.auditing.Auditable#setCreatedDate(org.joda.time | ||
* .DateTime) | ||
*/ | ||
public void setCreatedDate(final DateTime createdDate) { | ||
|
||
this.createdDate = null == createdDate ? null : createdDate.toDate(); | ||
} | ||
|
||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see org.synyx.hades.domain.auditing.Auditable#getLastModifiedBy() | ||
*/ | ||
public U getLastModifiedBy() { | ||
|
||
return lastModifiedBy; | ||
} | ||
|
||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see | ||
* org.synyx.hades.domain.auditing.Auditable#setLastModifiedBy(java.lang | ||
* .Object) | ||
*/ | ||
public void setLastModifiedBy(final U lastModifiedBy) { | ||
|
||
this.lastModifiedBy = lastModifiedBy; | ||
} | ||
|
||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see org.synyx.hades.domain.auditing.Auditable#getLastModifiedDate() | ||
*/ | ||
public DateTime getLastModifiedDate() { | ||
|
||
return null == lastModifiedDate ? null : new DateTime(lastModifiedDate); | ||
} | ||
|
||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see | ||
* org.synyx.hades.domain.auditing.Auditable#setLastModifiedDate(org.joda | ||
* .time.DateTime) | ||
*/ | ||
public void setLastModifiedDate(final DateTime lastModifiedDate) { | ||
|
||
this.lastModifiedDate = | ||
null == lastModifiedDate ? null : lastModifiedDate.toDate(); | ||
} | ||
} |
Oops, something went wrong.