jpa 表字段转bean对象

Posted 骚年轻狂

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jpa 表字段转bean对象相关的知识,希望对你有一定的参考价值。

select ‘private ‘ || decode(v_type, ‘int‘, ‘Integer‘, ‘float‘, ‘Double‘, ‘date‘, ‘Date‘, ‘String‘) || ‘ ‘ || v_name || ‘;‘ from
(
select column_id, column_name,
case when instr(v_name, ‘_‘) > 0 then substr(v_name, 1, instr(v_name, ‘_‘) - 1) || upper(substr(v_name, instr(v_name, ‘_‘) + 1, 1)) || lower(substr(v_name, instr(v_name, ‘_‘) + 2)) else v_name end v_name, v_type
from
(
select column_id, column_name, (case length(substr(column_name, 1, instr(column_name, ‘_‘) - 1)) when 1 then substr(column_name, 1, 1) else
lower(substr(column_name, 1, instr(column_name, ‘_‘) - 1)) end) || substr(column_name, instr(column_name, ‘_‘) + 1, 1) || lower(substr(column_name, instr(column_name, ‘_‘) + 2)) v_name,
(case when data_type = ‘NUMBER‘ and data_scale > 0 then ‘float‘ else (case data_type when ‘NUMBER‘ then ‘int‘ when ‘DATE‘ then ‘date‘ else ‘string‘ end) end) v_type
from user_tab_columns where table_name = ‘MZGL_BRSFMX‘ --order by column_id
) --order by column_id
) order by column_id;

declare
r_return varchar2(200);
v_sql varchar2(1000);
CURSOR C_AGE IS SELECT column_name FROM all_tab_columns where table_name=‘MZGL_BRSFMX‘ order by column_id;

begin
v_sql:=‘‘;
FOR R_DT IN C_AGE LOOP

r_return:= (case length(substr(R_DT.column_name, 1, instr(R_DT.column_name, ‘_‘) - 1)) when 1 then substr(R_DT.column_name, 1, 1) else
lower(substr(R_DT.column_name, 1, instr(R_DT.column_name, ‘_‘) - 1)) end) || substr(R_DT.column_name, instr(R_DT.column_name, ‘_‘) + 1, 1) || lower(substr(R_DT.column_name, instr(R_DT.column_name, ‘_‘) + 2)) ;
--r_return:= R_DT.column_name;
v_sql:=v_sql||‘,"‘||r_return||‘"‘;
END LOOP;
dbms_output.put_line(v_sql);
end;

以上是关于jpa 表字段转bean对象的主要内容,如果未能解决你的问题,请参考以下文章

JPA 表继承和对象映射

jpa 实体bean中如何定义非映射字段

JPA批注参考(转)

EJB_开发单表映射的实体bean

spring data jpa自定义bean字段映射

jstl标签和el表达式如何输出list中的object对象,object对象是数据库多表查询的结果,不是一个bean的字段