将数字字段转换为特定长度的varchar

时间:2018-01-11 09:27:21

标签: spring jpa spring-data-jpa jpa-2.0 jpa-criteria

我想要连接到其他字符串的实体中有一个数字namespace JsonDEMO { public class Rootobject { public Foo foo { get; set; } } public class Foo { public Resources Resources { get; set; } } public class Resources { public string resourceUri { get; set; } public string location { get; set; } public Tags tags { get; set; } } public class Tags { public string displayName { get; set; } public string containerregistry { get; set; } } class Program { static void Main(string[] args) { string jsonString = "{'foo':{'Resources':{'resourceUri':'/xf/b/rs/RA-a-675e/fo/age/s/m78','location':'us','tags':{'displayName':'As storage','containerregistry':'dd'}}}}"; var deserializedRootObject = Newtonsoft.Json.JsonConvert.DeserializeObject<Rootobject>(jsonString); System.Console.WriteLine(deserializedRootObject.foo.Resources.resourceUri); System.Console.WriteLine(deserializedRootObject.foo.Resources.location); System.Console.WriteLine(deserializedRootObject.foo.Resources.tags.displayName); System.Console.WriteLine(deserializedRootObject.foo.Resources.tags.containerregistry); } } } 字段。现在我正在做:

id

有效并且已翻译为cb.concat( from.get("id").as(String.class) , otherString )

我希望能够将其转换为长度为20 CAST(mytable.id AS VARCHAR(255)的varchar,因为查询的性能会呈指数级增长。

关于如何做的任何想法?

0 个答案:

没有答案