Fala galera, estamos convertendo nossa aplicação BC4J para Hibernate (adivinhem porque).
E estou com um problema sério de entendimento.
No BC4J existem alguns arquivos XML que são representações de Views e que são selects feitos na mão com vários joins e talz.
Existem muitos casos que não estou conseguindo entender oque fazer para realziar a conversão, segue um exemplo de um arquivo de View que preciso converter :
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
<ViewObject
Name="GapProgramacaoView"
BindingStyle="JDBC"
CustomQuery="true"
RowClass="br.com.cvrd.lg.equipagemferroviaria.equipfer.escala.geracao.model.view.GapProgramacaoViewRowImpl"
ComponentClass="br.com.cvrd.lg.equipagemferroviaria.equipfer.escala.geracao.model.view.GapProgramacaoViewImpl"
MsgBundleClass="oracle.jbo.common.JboResourceBundle"
UseGlueCode="false" >
<SQLQuery><![CDATA[
select Consoli.CodDestacamento CodDestacamento,
Consoli.NumSeqDestacamento NumSeqDestacamento,
Consoli.Categoria Categoria,
Consoli.Empresa Empresa,
Consoli.Matricula Matricula,
Consoli.IdEquipagem IdEquipagem,
Consoli.DataInicioGap DataInicioGap,
Consoli.DataProx DataProx,
Consoli.DiasGap DiasGap,
nvl(Consoli.NomeEmpregado,
(select empregado.PPAPNOME
from ppaeferv empregado
where empregado.PPAPEMPR = Consoli.Empresa
and empregado.PPAPMATR = Consoli.Matricula)) NomeEmpregado,
Consoli.DescDestacamento DescDestacamento
from (select loc.RIECDLOC CodDestacamento,
loc.RIEDRLOC DescDestacamento,
Tarefa.numSeqDestac NumSeqDestacamento,
Tarefa.categoria Categoria,
nvl(emp.af3pempr, emp.af3emprs) Empresa,
nvl(emp.af3pmatr, emp.af3pmatc) Matricula,
Tarefa.idEqp IdEquipagem,
emp.af3pnome NomeEmpregado,
(Tarefa.data_base + 1) DataInicioGap,
(select min(Proximas.afehopro)
from afetaprt Proximas
where Proximas.afeident = Tarefa.idEqp
and Proximas.afeidver = 1
and Proximas.afehopro >=
(Tarefa.data_base + 1)) DataProx,
(select trunc(nvl(min(Proximas.afehopro), SYSDATE))
from afetaprt Proximas
where Proximas.afeident = Tarefa.idEqp
and Proximas.afeidver = 1
and Proximas.afehopro >= (Tarefa.data_base + 1)) -
(Tarefa.data_base + 1) DiasGap
from (select trunc(tar.afehopro) data_base,
tar.afeident idEqp,
esca.afanseql numSeqDestac,
esca.afacdcat categoria
from afetaprt tar, afaescat esca
where tar.afenseqt = esca.afanuseq
and tar.afeidver = 1
and tar.afehopro > ?
and tar.afehopro < ?
and esca.afacdfer = ?) Tarefa,
rieeferv loc,
af3cempt emp
where Tarefa.numSeqDestac = loc.RIENUSEQ
and emp.af3ident = Tarefa.idEqp
and emp.af3escal = 'N'
and emp.af3isaeq = 'A') Consoli
where Consoli.DiasGap > 0
]]></SQLQuery>
<DesignTime>
<Attr Name="_isCodegen" Value="true" />
<Attr Name="_version" Value="9.0.3.11.88" />
<Attr Name="_CodeGenFlagNew" Value="36" />
</DesignTime>
<ViewAttribute
Name="CodDestacamento"
IsPersistent="false"
IsNotNull="true"
Precision="5"
Type="java.lang.String"
AliasName="CODDESTACAMENTO"
ColumnType="VARCHAR2"
Expression="CODDESTACAMENTO"
SQLType="VARCHAR" >
<DesignTime>
<Attr Name="_DisplaySize" Value="5" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="NumSeqDestacamento"
IsPersistent="false"
IsNotNull="true"
Precision="9"
Scale="0"
Type="java.lang.Integer"
AliasName="NUMSEQDESTACAMENTO"
ColumnType="VARCHAR2"
Expression="NUMSEQDESTACAMENTO"
SQLType="NUMERIC" >
<DesignTime>
<Attr Name="_DisplaySize" Value="22" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="Categoria"
IsPersistent="false"
IsNotNull="true"
Precision="4"
Type="java.lang.String"
AliasName="CATEGORIA"
ColumnType="VARCHAR2"
Expression="CATEGORIA"
SQLType="VARCHAR" >
<DesignTime>
<Attr Name="_DisplaySize" Value="4" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="Empresa"
IsPersistent="false"
Precision="2"
Type="java.lang.String"
AliasName="EMPRESA"
ColumnType="VARCHAR2"
Expression="EMPRESA"
SQLType="VARCHAR" >
<DesignTime>
<Attr Name="_DisplaySize" Value="2" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="Matricula"
IsPersistent="false"
Precision="20"
Type="java.lang.String"
AliasName="MATRICULA"
ColumnType="VARCHAR2"
Expression="MATRICULA"
SQLType="VARCHAR" >
<DesignTime>
<Attr Name="_DisplaySize" Value="20" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="IdEquipagem"
IsPersistent="false"
IsNotNull="true"
Precision="5"
Scale="0"
Type="java.lang.Integer"
AliasName="IDEQUIPAGEM"
ColumnType="VARCHAR2"
Expression="IDEQUIPAGEM"
SQLType="NUMERIC" >
<DesignTime>
<Attr Name="_DisplaySize" Value="22" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="DataInicioGap"
IsPersistent="false"
Precision="255"
Type="oracle.jbo.domain.Date"
AliasName="DATAINICIOGAP"
ColumnType="VARCHAR2"
Expression="DATAINICIOGAP"
SQLType="DATE" >
<DesignTime>
<Attr Name="_DisplaySize" Value="7" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="DataProx"
IsPersistent="false"
Precision="255"
Type="oracle.jbo.domain.Date"
AliasName="DATAPROX"
ColumnType="VARCHAR2"
Expression="DATAPROX"
SQLType="DATE" >
<DesignTime>
<Attr Name="_DisplaySize" Value="7" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="DiasGap"
IsPersistent="false"
Precision="255"
Type="java.lang.Integer"
AliasName="DIASGAP"
ColumnType="VARCHAR2"
Expression="DIASGAP"
SQLType="NUMERIC" >
<DesignTime>
<Attr Name="_DisplaySize" Value="22" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="NomeEmpregado"
IsPersistent="false"
Precision="45"
Type="java.lang.String"
AliasName="NOMEEMPREGADO"
ColumnType="VARCHAR2"
Expression="NOMEEMPREGADO"
SQLType="VARCHAR" >
<DesignTime>
<Attr Name="_DisplaySize" Value="45" />
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="DescDestacamento"
IsPersistent="false"
IsNotNull="true"
Precision="10"
Type="java.lang.String"
AliasName="DESCDESTACAMENTO"
ColumnType="VARCHAR2"
Expression="DESCDESTACAMENTO"
SQLType="VARCHAR" >
<DesignTime>
<Attr Name="_DisplaySize" Value="10" />
</DesignTime>
</ViewAttribute>
</ViewObject>
select Consoli.CodDestacamento CodDestacamento,
Consoli.NumSeqDestacamento NumSeqDestacamento,
Consoli.Categoria Categoria,
Consoli.Empresa Empresa,
Consoli.Matricula Matricula,
Consoli.IdEquipagem IdEquipagem,
Consoli.DataInicioGap DataInicioGap,
Consoli.DataProx DataProx,
Consoli.DiasGap DiasGap,
nvl(Consoli.NomeEmpregado,
(select empregado.PPAPNOME
from ppaeferv empregado
where empregado.PPAPEMPR = Consoli.Empresa
and empregado.PPAPMATR = Consoli.Matricula)) NomeEmpregado,
Consoli.DescDestacamento DescDestacamento
from (select loc.RIECDLOC CodDestacamento,
loc.RIEDRLOC DescDestacamento,
Tarefa.numSeqDestac NumSeqDestacamento,
Tarefa.categoria Categoria,
nvl(emp.af3pempr, emp.af3emprs) Empresa,
nvl(emp.af3pmatr, emp.af3pmatc) Matricula,
Tarefa.idEqp IdEquipagem,
emp.af3pnome NomeEmpregado,
(Tarefa.data_base + 1) DataInicioGap,
(select min(Proximas.afehopro)
from afetaprt Proximas
where Proximas.afeident = Tarefa.idEqp
and Proximas.afeidver = 1
and Proximas.afehopro >=
(Tarefa.data_base + 1)) DataProx,
(select trunc(nvl(min(Proximas.afehopro), SYSDATE))
from afetaprt Proximas
where Proximas.afeident = Tarefa.idEqp
and Proximas.afeidver = 1
and Proximas.afehopro >= (Tarefa.data_base + 1)) -
(Tarefa.data_base + 1) DiasGap
from (select trunc(tar.afehopro) data_base,
tar.afeident idEqp,
esca.afanseql numSeqDestac,
esca.afacdcat categoria
from afetaprt tar, afaescat esca
where tar.afenseqt = esca.afanuseq
and tar.afeidver = 1
and tar.afehopro > ?
and tar.afehopro < ?
and esca.afacdfer = ?) Tarefa,
rieeferv loc,
af3cempt emp
where Tarefa.numSeqDestac = loc.RIENUSEQ
and emp.af3ident = Tarefa.idEqp
and emp.af3escal = 'N'
and emp.af3isaeq = 'A') Consoli
where Consoli.DiasGap > 0
Podem me ajudar como começar a convertar esta tecnologia tão boa para o Hibernate ?
Obrigado e abraço a todos.