Hello,
I'm new to hibernate. I use it with Firebird. He needs to process SQL query eclipses which uses the system tables Fierbird to obtain metadata. How should a POJO to get a result this query?
Code:
SELECT
IIF(b.rdb$field_name = f.rdb$field_name,1,0) AS primary_key, b.rdb$field_name AS field,
IIF(POSITION('RDB$' IN c.rdb$field_name) = 0,c.rdb$field_name,
CASE
WHEN (((c.rdb$field_type=14) OR (c.rdb$field_type=15)) AND (c.rdb$field_length = 16) AND (c.rdb$character_set_id =1) ) THEN 'GUID'
WHEN (c.rdb$field_type= 261) AND (c.rdb$field_sub_type =1) THEN 'TEXT'
WHEN (c.rdb$field_type= 261) AND (c.rdb$field_sub_type <>1) THEN 'BINARY'
WHEN (((c.rdb$field_type=14)OR(c.rdb$field_type=15)) AND c.rdb$field_length <>16 AND c.rdb$character_set_id <>1 ) THEN 'CHAR'
WHEN (c.rdb$field_type=40 OR c.rdb$field_type=41) THEN 'TEXT'
WHEN (c.rdb$field_type=11 OR c.rdb$field_type=27) THEN 'DOUBLE'
WHEN c.rdb$field_type=10 THEN 'FLOAT'
WHEN ((c.rdb$field_type=9) OR (c.rdb$field_type=16) OR (c.rdb$field_type=45)) AND (c.rdb$field_scale < 0) THEN 'DECIMAL'
WHEN ((c.rdb$field_type=9) OR (c.rdb$field_type=16) OR (c.rdb$field_type=45)) AND (c.rdb$field_scale >= 0) THEN 'BIGINT'
WHEN (c.rdb$field_type=8) AND (c.rdb$field_scale < 0) THEN 'DECIMAL'
WHEN (c.rdb$field_type=8) AND (c.rdb$field_scale >= 0) THEN 'INTEGER'
WHEN (c.rdb$field_type=7) AND (c.rdb$field_scale < 0) THEN 'DECIMAL'
WHEN (c.rdb$field_type=7) AND (c.rdb$field_scale >= 0) THEN 'SMALLINT'
WHEN c.rdb$field_type=12 THEN 'DATE'
WHEN c.rdb$field_type=13 THEN 'TIME'
WHEN c.rdb$field_type=35 THEN 'TIMESTAMP'
WHEN (c.rdb$field_type=37) OR (c.rdb$field_type=38) THEN 'VARCHAR'
ELSE 'UNKNOWN' END) AS TYPE,
COALESCE(b.rdb$null_flag,0) AS notnull,
c.rdb$field_length AS LENGTH,
abs(c.rdb$field_scale) AS scale,
a.rdb$relation_name AS table_name
FROM rdb$relations a
INNER JOIN rdb$relation_fields b ON a.rdb$relation_name = b.rdb$relation_name
INNER JOIN rdb$fields c ON b.rdb$field_source = c.rdb$field_name
INNER JOIN rdb$types d ON c.rdb$field_type = d.rdb$type
INNER JOIN rdb$relation_constraints e ON e.rdb$relation_name = a.rdb$relation_name
INNER JOIN rdb$index_segments f ON f.rdb$index_name = e.rdb$index_name
WHERE a.rdb$system_flag = 0 AND d.rdb$field_name = 'RDB$FIELD_TYPE' AND e.rdb$constraint_type = 'PRIMARY KEY' AND a.rdb$relation_name = ?
ORDER BY a.rdb$relation_name, b.rdb$field_id
Regards