-
Notifications
You must be signed in to change notification settings - Fork 359
DATAJDBC-99 - Repository support basics #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b2d4de4
11df79b
720a0a3
82f73a3
3efb2a4
177f052
f4b5f2b
84a8e0b
d4238f2
bde86f7
afb021c
173a4be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lombok.nonNull.exceptionType = IllegalArgumentException | ||
lombok.log.fieldName = LOG |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<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>org.springframework.data</groupId> | ||
<artifactId>spring-data-jdbc</artifactId> | ||
<version>1.0.0.DATAJDBC-99-SNAPSHOT</version> | ||
|
||
<name>Spring Data JDBC</name> | ||
<description>Spring Data module for JDBC repositories.</description> | ||
<url>http://projects.spring.io/spring-data-jdbc</url> | ||
|
||
<parent> | ||
<groupId>org.springframework.data.build</groupId> | ||
<artifactId>spring-data-parent</artifactId> | ||
<version>2.0.0.BUILD-SNAPSHOT</version> | ||
</parent> | ||
|
||
<properties> | ||
|
||
<dist.key>DATAJDBC</dist.key> | ||
|
||
<springdata.commons>2.0.0.BUILD-SNAPSHOT</springdata.commons> | ||
|
||
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis> | ||
<hsqldb1>1.8.0.10</hsqldb1> | ||
|
||
</properties> | ||
|
||
<profiles> | ||
<profile> | ||
<id>release</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jfrog.buildinfo</groupId> | ||
<artifactId>artifactory-maven-plugin</artifactId> | ||
<inherited>false</inherited> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<profile> | ||
<id>all-dbs</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>mysql-test</id> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<includes> | ||
<include>**/*IntegrationTests.java</include> | ||
</includes> | ||
<systemPropertyVariables> | ||
<spring.profiles.active>mysql</spring.profiles.active> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>postgres-test</id> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<includes> | ||
<include>**/*IntegrationTests.java</include> | ||
</includes> | ||
<systemPropertyVariables> | ||
<spring.profiles.active>postgres</spring.profiles.active> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>spring-data-commons</artifactId> | ||
<version>${springdata.commons}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-tx</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-jdbc</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hsqldb</groupId> | ||
<artifactId>hsqldb</artifactId> | ||
<version>2.2.8</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>3.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.41</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<version>42.0.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.12</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<plugins> | ||
|
||
<!-- | ||
Jacoco plugin redeclared to make sure it's downloaded and | ||
the agents can be explicitly added to the test executions. | ||
--> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
<version>${jacoco}</version> | ||
<configuration> | ||
<destFile>${jacoco.destfile}</destFile> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>jacoco-initialize</id> | ||
<goals> | ||
<goal>prepare-agent</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-test</id> | ||
<configuration> | ||
<includes> | ||
<include>**/*Tests.java</include> | ||
</includes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
</plugin> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we using this plugin for anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed by the release infrastructure. Same for all other Spring Data modules. |
||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>wagon-maven-plugin</artifactId> | ||
</plugin> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question. If we aren't doing anything with it, maybe we don't need it, yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed by the release infrastructure. Same for all other Spring Data modules. |
||
<plugin> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>asciidoctor-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spring-libs-snapshot</id> | ||
<url>https://repo.spring.io/libs-snapshot</url> | ||
</repository> | ||
</repositories> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>spring-plugins-snapshot</id> | ||
<url>https://repo.spring.io/plugins-snapshot</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
./start-all-dbs.sh && mvn clean install -Pall-dbs && ./stop-all-dbs.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2017 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.jdbc.mapping.context; | ||
|
||
import org.springframework.data.jdbc.mapping.model.BasicJdbcPersistentProperty; | ||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentEntityImpl; | ||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentProperty; | ||
import org.springframework.data.mapping.context.AbstractMappingContext; | ||
import org.springframework.data.mapping.context.MappingContext; | ||
import org.springframework.data.mapping.model.Property; | ||
import org.springframework.data.mapping.model.SimpleTypeHolder; | ||
import org.springframework.data.util.TypeInformation; | ||
|
||
/** | ||
* {@link MappingContext} implementation for JDBC. | ||
* | ||
* @author Jens Schauder | ||
* @since 2.0 | ||
*/ | ||
public class JdbcMappingContext extends AbstractMappingContext<JdbcPersistentEntityImpl<?>, JdbcPersistentProperty> { | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.springframework.data.mapping.context.AbstractMappingContext#createPersistentEntity(org.springframework.data.util.TypeInformation) | ||
*/ | ||
@Override | ||
protected <T> JdbcPersistentEntityImpl<?> createPersistentEntity(TypeInformation<T> typeInformation) { | ||
return new JdbcPersistentEntityImpl<>(typeInformation); | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.springframework.data.mapping.context.AbstractMappingContext#createPersistentProperty(org.springframework.data.mapping.model.Property, org.springframework.data.mapping.model.MutablePersistentEntity, org.springframework.data.mapping.model.SimpleTypeHolder) | ||
*/ | ||
@Override | ||
protected JdbcPersistentProperty createPersistentProperty(Property property, JdbcPersistentEntityImpl<?> owner, | ||
SimpleTypeHolder simpleTypeHolder) { | ||
return new BasicJdbcPersistentProperty(property, owner, simpleTypeHolder); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2017 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.jdbc.mapping.event; | ||
|
||
import org.springframework.data.jdbc.mapping.event.Identifier.Specified; | ||
|
||
/** | ||
* Gets published after instantiation and setting of all the properties of an entity. This allows to do some | ||
* postprocessing of entities. | ||
* | ||
* @author Jens Schauder | ||
* @since 2.0 | ||
*/ | ||
public class AfterCreation extends JdbcEventWithIdAndEntity { | ||
|
||
private static final long serialVersionUID = -4185777271143436728L; | ||
|
||
/** | ||
* @param id of the entity | ||
* @param entity the newly instantiated entity. | ||
*/ | ||
public AfterCreation(Specified id, Object entity) { | ||
super(id, entity); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's a one-to-one copy from the JPA setup? Wonder whether need the split up really as in JPA we have to use it as different Java agents need to be in place for different persistence providers. I'd like to avoid the additional setup if necessary.