开发者

From SQL with Left Outer Join to JPQL or Native SQL

Hiya all, my problem is related to converting one of the Sql with left join into jpa and entity structure, but i am stucked with it here is my sql

    SELECT   
     *
     FROM X_TABLE LEFT OUTER JOIN Y_TABLE  
     ON 
     TO_CHAR (X_TABLE.TIME1, 'HH24:MI') = 
        TO_CHAR (Y_TABLE.TIME1, 'HH24:MI') 
        AND
          TO_DATE(Y_TABLE.DATE1) = TO_DATE('10/10/2010','dd/MM/yyyy')
           AND 
                Y_TABLE.Z_TABLE_ID =X_TABLE.Z_TABLE_ID,
                  Z_TABLE 

     Where X_TABLE.Z_TABLE_ID =Z_TABLE.ID

Y_TABLE has foreign key of X_table but when i query with this sql , X_TABLE which has no foreign key of Y_TABLE , where will my columns of Y_TABLE be stored in?

the relationship between Y_TABLE and X_TABLE is ManyToOne , so in the Y_TABLE entity i have @ManyToOne X_TABLE field, when i map inversely this relationship in X_TABLE via mapped i am having a Y_TABLE list when i query this sql i am getting just a row with two tables columns?

but in entity meaning i am having a list of Y_TABLE?

how i can get the all returnin开发者_Go百科g columns in one entity, what should i do for that?

thanx all system we have been working like below

eclipselink 2.0.1,Glassfish 3.0.1,JSF 2


Your query seems very complex. Perhaps start by explaining your object model, and what you are trying to do, and what you want back from your query.

Your function usage seems odd, why do you want to compare your times as chars and your chars as dates?

If your database is very cryptic, you may consider defining a view and mapping to it instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜