话不多说直接上代码。
生成VO的脚本:
SELECT ‘/**‘ || T2.COMMENTS || ‘*/ @Column(name="‘ || T1.ColUMN_name || ‘")‘ || ‘private ‘ || CASE WHEN T1.DATA_TYPE liKE ‘VARCHAR%‘ THEN ‘String ‘ WHEN T1.DATA_TYPE liKE ‘DATE%‘ THEN ‘Date ‘ WHEN T1.DATA_SCALE <> NulL OR T1.DATA_SCALE <> 0 THEN ‘Double ‘ WHEN T1.DATA_TYPE liKE ‘NUMBER%‘ THEN ‘int ‘ WHEN T1.DATA_TYPE liKE ‘Timestamp%‘ THEN ‘Timestamp ‘ END || LOWER(SUBSTR(T1.ColUMN_name,1,1)) || SUBSTR(REPLACE(INITCAP(T1.ColUMN_name),‘_‘,‘‘),2) || ‘;‘ FROM USER_TAB_ColUMNS T1,USER_Col_COMMENTS T2 WHERE T1.table_name = T2.table_name AND T1.ColUMN_name = T2.ColUMN_name AND T1.table_name IN (‘表名‘)
生成DaO的脚本:
SELECT ‘/**‘ || T2.COMMENTS || ‘*/ ‘ || ‘private ‘ || CASE WHEN T1.DATA_TYPE liKE ‘VARCHAR%‘ THEN ‘String ‘ WHEN T1.DATA_TYPE liKE ‘DATE%‘ THEN ‘Date ‘ WHEN T1.DATA_SCALE <> NulL OR T1.DATA_SCALE <> 0 THEN ‘Double ‘ WHEN T1.DATA_TYPE liKE ‘NUMBER%‘ THEN ‘int ‘ WHEN T1.DATA_TYPE liKE ‘Timestamp%‘ THEN ‘Timestamp ‘ END || LOWER(SUBSTR(T1.ColUMN_name,USER_Col_COMMENTS T2 WHERE T1.table_name = T2.table_name AND T1.ColUMN_name = T2.ColUMN_name AND T1.table_name IN (‘表名‘)
将生成出来的数据复制到java类里,格式化就OK了。
总结以上是内存溢出为你收集整理的使用oracle脚本生成VO和Dao全部内容,希望文章能够帮你解决使用oracle脚本生成VO和Dao所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)