zoukankan      html  css  js  c++  java
  • sqlserver 将表转为java实体类型

    转自网络:

    select '/**'+char(13)+char(10)    
    +'*'+isnull(CONVERT(VARCHAR(100),g.value),'') + char(13)+char(10)    
    +'*/'+char(13)+char(10)    
    +'@TableField("'+ a.name +'")' + char(13)+char(10) 
    +'private '+    
    case b.name  
    WHEN 'bigint' then 'Long'       
    WHEN 'int' then 'Integer'    
    WHEN 'smallint' then 'Short'    
    when 'varchar' then 'String'    
    when 'nvarchar' then 'String'    
    when 'text' then 'String'   
    when 'decimal' then 'BigDecimal'     
    when 'bit' then 'Boolean'  
    when 'float' then 'BigDecimal'     
    when 'datetime' then 'LocalDateTime' end    
    +' '+lower(substring(a.name,1,1))+SUBSTRING(a.name,2,len(a.name)-1)--保持字段名称的原始大小写则直接用a.name    
    +';'+char(13)+char(10)  
    --,b.name,a.max_length ,g.value,b.name,a.name    
    from sys.columns a 
    LEFT join sys.types b on a.user_type_id=b.user_type_id     
    LEFT join sys.extended_properties g on a.object_id=g.major_id and a.column_id=g.minor_id    
    where object_id=object_id('dbo.Business') ;--其中Business为表名   
  • 相关阅读:
    第0次作业
    第4次作业
    第3次作业
    第2次作业
    C#浮点数保留位数
    第0次作业
    软件工程第4次作业
    软件工程第3次作业
    软件工程第2次作业
    软件工程第1次作业
  • 原文地址:https://www.cnblogs.com/ariter/p/14205691.html
Copyright © 2011-2022 走看看