DATAMONGO-1289 - Polishing.
Some additional JavaDoc and comment removal. Original pull request: #333.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2015 by the original author(s).
|
* Copyright 2011-2015 by the original author(s).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -46,6 +46,13 @@ public class MappingMongoEntityInformation<T, ID extends Serializable> extends P
|
|||||||
this(entity, null, null);
|
this(entity, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link MappingMongoEntityInformation} for the given {@link MongoPersistentEntity} and fallback
|
||||||
|
* identifier type.
|
||||||
|
*
|
||||||
|
* @param entity must not be {@literal null}.
|
||||||
|
* @param fallbackIdType can be {@literal null}.
|
||||||
|
*/
|
||||||
public MappingMongoEntityInformation(MongoPersistentEntity<T> entity, Class<ID> fallbackIdType) {
|
public MappingMongoEntityInformation(MongoPersistentEntity<T> entity, Class<ID> fallbackIdType) {
|
||||||
this(entity, (String) null, fallbackIdType);
|
this(entity, (String) null, fallbackIdType);
|
||||||
}
|
}
|
||||||
@@ -61,7 +68,17 @@ public class MappingMongoEntityInformation<T, ID extends Serializable> extends P
|
|||||||
this(entity, customCollectionName, null);
|
this(entity, customCollectionName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappingMongoEntityInformation(MongoPersistentEntity<T> entity, String customCollectionName, Class<ID> idType) {
|
/**
|
||||||
|
* Creates a new {@link MappingMongoEntityInformation} for the given {@link MongoPersistentEntity}, collection name
|
||||||
|
* and identifier type.
|
||||||
|
*
|
||||||
|
* @param entity must not be {@literal null}.
|
||||||
|
* @param customCollectionName can be {@literal null}.
|
||||||
|
* @param idType can be {@literal null}.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private MappingMongoEntityInformation(MongoPersistentEntity<T> entity, String customCollectionName,
|
||||||
|
Class<ID> idType) {
|
||||||
|
|
||||||
super(entity);
|
super(entity);
|
||||||
|
|
||||||
|
|||||||
@@ -108,8 +108,6 @@ public class MongoRepositoryFactory extends RepositoryFactorySupport {
|
|||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getEntityInformation(java.lang.Class)
|
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getEntityInformation(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
// TODO: would be worth discussing if we could alter RepositoryFactorySupport#getEntityInformation to be called with
|
|
||||||
// RepositoryMetadata instead of the acual domain type class.
|
|
||||||
public <T, ID extends Serializable> MongoEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
public <T, ID extends Serializable> MongoEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||||
return getEntityInformation(domainClass, null);
|
return getEntityInformation(domainClass, null);
|
||||||
}
|
}
|
||||||
@@ -121,8 +119,8 @@ public class MongoRepositoryFactory extends RepositoryFactorySupport {
|
|||||||
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(domainClass);
|
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(domainClass);
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new MappingException(String.format("Could not lookup mapping metadata for domain class %s!",
|
throw new MappingException(
|
||||||
domainClass.getName()));
|
String.format("Could not lookup mapping metadata for domain class %s!", domainClass.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MappingMongoEntityInformation<T, ID>((MongoPersistentEntity<T>) entity,
|
return new MappingMongoEntityInformation<T, ID>((MongoPersistentEntity<T>) entity,
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import com.mongodb.Mongo;
|
|||||||
import com.mongodb.MongoClient;
|
import com.mongodb.MongoClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Integration tests for DATAMONGO-1289.
|
||||||
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@@ -102,6 +104,7 @@ public class NoExplicitIdTests {
|
|||||||
* @see DATAMONGO-1289
|
* @see DATAMONGO-1289
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void saveAndRetrieveTypeWithoutIdPorpertyViaRepositoryFindOne() {
|
public void saveAndRetrieveTypeWithoutIdPorpertyViaRepositoryFindOne() {
|
||||||
|
|
||||||
TypeWithoutIdProperty noid = new TypeWithoutIdProperty();
|
TypeWithoutIdProperty noid = new TypeWithoutIdProperty();
|
||||||
|
|||||||
Reference in New Issue
Block a user