Merge pull request #102 from LucaLq/main

feat[orm]:the @Id annotation supports the ObjectId type
This commit is contained in:
godotg
2024-05-14 11:22:52 +08:00
committed by GitHub
@@ -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);
}
}