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为表名   
  • 相关阅读:
    tcl tk lappend
    file join
    [转载]强指针和弱指针
    DisplayHardware
    Android 十大调试方法
    C语言程序的外部变量与函数
    DisplayHardware
    Android 十大调试方法
    wifi连接流程分析
    [转载]强指针和弱指针
  • 原文地址:https://www.cnblogs.com/ariter/p/14205691.html
Copyright © 2011-2022 走看看