mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-20 08:24:16 +00:00
Merge pull request #102 from LucaLq/main
feat[orm]:the @Id annotation supports the ObjectId type
This commit is contained in:
@@ -39,6 +39,7 @@ import org.bson.Document;
|
||||
import org.bson.codecs.configuration.CodecRegistries;
|
||||
import org.bson.codecs.configuration.CodecRegistry;
|
||||
import org.bson.codecs.pojo.PojoCodecProvider;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
@@ -408,6 +409,8 @@ public class OrmManager implements IOrmManager {
|
||||
idFiledValue = RandomUtils.randomDouble();
|
||||
} else if (idFieldType.equals(String.class)) {
|
||||
idFiledValue = RandomUtils.randomString(10);
|
||||
} else if (idFieldType.equals(ObjectId.class)) {
|
||||
idFiledValue = new ObjectId();
|
||||
} else {
|
||||
throw new RunException("orm only supports int long float double String");
|
||||
}
|
||||
@@ -536,7 +539,9 @@ public class OrmManager implements IOrmManager {
|
||||
}
|
||||
|
||||
checkSubEntity(clazz, valueType);
|
||||
} else {
|
||||
} else if (ObjectId.class.isAssignableFrom(fieldType)){
|
||||
// do nothing
|
||||
}else {
|
||||
checkEntity(fieldType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user