12 changed files with 451 additions and 1 deletions
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<classpath> |
||||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java"/> |
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> |
||||
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/> |
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> |
||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> |
||||
<classpathentry kind="output" path="target/classes"/> |
||||
</classpath> |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<projectDescription> |
||||
<name>spring-data-mongodb-cross-store</name> |
||||
<comment></comment> |
||||
<projects> |
||||
</projects> |
||||
<buildSpec> |
||||
<buildCommand> |
||||
<name>org.eclipse.ajdt.core.ajbuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
<buildCommand> |
||||
<name>org.maven.ide.eclipse.maven2Builder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
</buildSpec> |
||||
<natures> |
||||
<nature>org.eclipse.ajdt.ui.ajnature</nature> |
||||
<nature>org.eclipse.jdt.core.javanature</nature> |
||||
<nature>org.maven.ide.eclipse.maven2Nature</nature> |
||||
</natures> |
||||
</projectDescription> |
||||
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
#Mon Feb 28 16:26:01 EST 2011 |
||||
eclipse.preferences.version=1 |
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 |
||||
org.eclipse.jdt.core.compiler.compliance=1.5 |
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
||||
org.eclipse.jdt.core.compiler.source=1.5 |
||||
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#Mon Feb 28 16:25:59 EST 2011 |
||||
activeProfiles= |
||||
eclipse.preferences.version=1 |
||||
fullBuildGoals=process-test-resources |
||||
resolveWorkspaceProjects=true |
||||
resourceFilterGoals=process-resources resources\:testResources |
||||
skipCompilerPlugin=true |
||||
version=1 |
||||
@ -0,0 +1,203 @@
@@ -0,0 +1,203 @@
|
||||
<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/maven-v4_0_0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>org.springframework.data</groupId> |
||||
<artifactId>spring-data-document-parent</artifactId> |
||||
<version>1.0.0.BUILD-SNAPSHOT</version> |
||||
<relativePath>../spring-data-document-parent/pom.xml</relativePath> |
||||
</parent> |
||||
<artifactId>spring-data-mongodb-cross-store</artifactId> |
||||
<packaging>jar</packaging> |
||||
<name>Spring Data MongoDB Cross-store Persistence Support</name> |
||||
<dependencies> |
||||
|
||||
<!-- Spring --> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-beans</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-tx</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-orm</artifactId> |
||||
</dependency> |
||||
|
||||
<!-- Spring Data --> |
||||
<dependency> |
||||
<groupId>org.springframework.data</groupId> |
||||
<artifactId>spring-data-commons-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.data</groupId> |
||||
<artifactId>spring-data-commons-aspects</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.data</groupId> |
||||
<artifactId>spring-data-mongodb</artifactId> |
||||
</dependency> |
||||
|
||||
|
||||
<!-- Logging --> |
||||
<dependency> |
||||
<groupId>org.slf4j</groupId> |
||||
<artifactId>slf4j-api</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.slf4j</groupId> |
||||
<artifactId>jcl-over-slf4j</artifactId> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.slf4j</groupId> |
||||
<artifactId>slf4j-log4j12</artifactId> |
||||
<scope>runtime</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>log4j</groupId> |
||||
<artifactId>log4j</artifactId> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>javax.mail</groupId> |
||||
<artifactId>mail</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>javax.jms</groupId> |
||||
<artifactId>jms</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>com.sun.jdmk</groupId> |
||||
<artifactId>jmxtools</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>com.sun.jmx</groupId> |
||||
<artifactId>jmxri</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
<scope>runtime</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>javax.annotation</groupId> |
||||
<artifactId>jsr250-api</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.mockito</groupId> |
||||
<artifactId>mockito-all</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>junit</groupId> |
||||
<artifactId>junit</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.aspectj</groupId> |
||||
<artifactId>aspectjrt</artifactId> |
||||
<version>${aspectj.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cglib</groupId> |
||||
<artifactId>cglib</artifactId> |
||||
<version>2.2</version> |
||||
</dependency> |
||||
|
||||
<!-- JPA --> |
||||
<dependency> |
||||
<groupId>org.hibernate.javax.persistence</groupId> |
||||
<artifactId>hibernate-jpa-2.0-api</artifactId> |
||||
<version>1.0.0.Final</version> |
||||
</dependency> |
||||
|
||||
<!-- For Tests --> |
||||
<dependency> |
||||
<groupId>org.hibernate</groupId> |
||||
<artifactId>hibernate-entitymanager</artifactId> |
||||
<version>3.5.5-Final</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>hsqldb</groupId> |
||||
<artifactId>hsqldb</artifactId> |
||||
<version>1.8.0.10</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>javax.validation</groupId> |
||||
<artifactId>validation-api</artifactId> |
||||
<version>1.0.0.GA</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.hibernate</groupId> |
||||
<artifactId>hibernate-validator</artifactId> |
||||
<version>4.0.2.GA</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
<repositories> |
||||
<repository> |
||||
<id>jboss-repository</id> |
||||
<name>JBoss Public Repository</name> |
||||
<url>http://repository.jboss.org/nexus/content/groups/public-jboss</url> |
||||
</repository> |
||||
<repository> |
||||
<id>spring-maven-snapshot</id> |
||||
<snapshots> |
||||
<enabled>true</enabled> |
||||
</snapshots> |
||||
<name>Springframework Maven SNAPSHOT Repository</name> |
||||
<url>http://maven.springframework.org/snapshot</url> |
||||
</repository> |
||||
</repositories> |
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.codehaus.mojo</groupId> |
||||
<artifactId>aspectj-maven-plugin</artifactId> |
||||
<version>1.2</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> |
||||
<goal>test-compile</goal> |
||||
</goals> |
||||
</execution> |
||||
</executions> |
||||
<configuration> |
||||
<outxml>true</outxml> |
||||
<aspectLibraries> |
||||
<aspectLibrary> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-aspects</artifactId> |
||||
</aspectLibrary> |
||||
<!--aspectLibrary> |
||||
<groupId>org.springframework.data</groupId> |
||||
<artifactId>spring-data-commons-aspects</artifactId> |
||||
</aspectLibrary--> |
||||
</aspectLibraries> |
||||
<source>1.6</source> |
||||
<target>1.6</target> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
||||
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
package org.springframework.persistence.document; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation to denote an object that should be transparently persisted |
||||
* using MongoDB |
||||
* |
||||
* @author Thomas Risberg |
||||
*/ |
||||
|
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Target(ElementType.TYPE) |
||||
public @interface DocumentEntity { |
||||
|
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
package org.springframework.data.document.persistence; |
||||
|
||||
import javax.persistence.Entity; |
||||
|
||||
@Entity |
||||
public class Account { |
||||
|
||||
private String name; |
||||
|
||||
private float balance; |
||||
|
||||
private String friendlyName; |
||||
|
||||
private String whatever; |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public float getBalance() { |
||||
return balance; |
||||
} |
||||
|
||||
public void setBalance(float balance) { |
||||
this.balance = balance; |
||||
} |
||||
|
||||
public String getFriendlyName() { |
||||
return friendlyName; |
||||
} |
||||
|
||||
public void setFriendlyName(String friendlyName) { |
||||
this.friendlyName = friendlyName; |
||||
} |
||||
|
||||
public String getWhatever() { |
||||
return whatever; |
||||
} |
||||
|
||||
public void setWhatever(String whatever) { |
||||
this.whatever = whatever; |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
package org.springframework.data.document.persistence; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.test.annotation.Rollback; |
||||
import org.springframework.test.context.ContextConfiguration; |
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import com.mongodb.Mongo; |
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class) |
||||
@ContextConfiguration(locations = "classpath:/META-INF/spring/applicationContext.xml") |
||||
public class CrossStoreMongoTests { |
||||
|
||||
@Autowired |
||||
private Mongo mongo; |
||||
|
||||
@Test |
||||
// @Transactional
|
||||
// @Rollback(false)
|
||||
public void testUserConstructor() { |
||||
int age = 33; |
||||
MongoPerson p = new MongoPerson("Thomas", age); |
||||
//Assert.assertEquals(p.getRedisValue().getString("RedisPerson.name"), p.getName());
|
||||
Assert.assertEquals(age, p.getAge()); |
||||
p.birthday(); |
||||
Assert.assertEquals(1 + age, p.getAge()); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
package org.springframework.data.document.persistence; |
||||
|
||||
import org.springframework.persistence.RelatedEntity; |
||||
import org.springframework.persistence.document.DocumentEntity; |
||||
|
||||
@DocumentEntity |
||||
public class MongoPerson { |
||||
|
||||
// TODO only public because of AspectJ bug
|
||||
public String name; |
||||
|
||||
public int age; |
||||
|
||||
public java.util.Date birthDate; |
||||
|
||||
// TODO only public to check weaving bug--
|
||||
// seems to work whereas private didn't
|
||||
@RelatedEntity |
||||
public Account account; |
||||
|
||||
public MongoPerson(String name, int age) { |
||||
this.name = name; |
||||
this.age = age; |
||||
this.birthDate = new java.util.Date(); |
||||
} |
||||
|
||||
public void birthday() { |
||||
++age; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public int getAge() { |
||||
return age; |
||||
} |
||||
|
||||
public void setAge(int age) { |
||||
this.age = age; |
||||
} |
||||
|
||||
public java.util.Date getBirthDate() { |
||||
return birthDate; |
||||
} |
||||
|
||||
public void setBirthDate(java.util.Date birthDate) { |
||||
this.birthDate = birthDate; |
||||
} |
||||
|
||||
public Account getAccount() { |
||||
return account; |
||||
} |
||||
|
||||
public void setAccount(Account account) { |
||||
this.account = account; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> |
||||
|
||||
<bean id="mongo" class="org.springframework.data.document.mongodb.MongoFactoryBean"> |
||||
<property name="host" value="localhost" /> |
||||
<property name="port" value="27017" /> |
||||
</bean> |
||||
|
||||
<bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> |
||||
<constructor-arg ref="mongo" /> |
||||
<constructor-arg value="database" /> |
||||
<property name="defaultCollectionName" value="springdata" /> |
||||
</bean> |
||||
|
||||
<bean class="org.springframework.data.document.mongodb.MongoExceptionTranslator" /> |
||||
|
||||
</beans> |
||||
Loading…
Reference in new issue