如何基于第4个表属性作为连接条件在hibernate中添加左连接多个表

时间:2017-02-08 11:55:36

标签: hibernate hql

我有4张桌子

A,B,C,d

我想执行以下SQL查询:

Highcharts.stockChart('container', {
    chart: {
 marginBottom: 70 /*marign between chart area and bottom*/
    },

    title: {
        text: 'AAPL stock price by minute'
    },

    rangeSelector: {
        buttons: [{
            type: 'hour',
            count: 1,
            text: '1h'
        }, {
            type: 'day',
            count: 1,
            text: '1D'
        }, {
            type: 'all',
            count: 1,
            text: 'All'
        }],
        selected: 1,
        padding: 50,
    buttonPosition: {
            y: 360, /*Position of button from top*/
        },

    },
        navigator: {
         top:300, /*Postion of navigator from top*/
       },
    series: [{
        name: 'AAPL',
        type: 'candlestick',
        data: data,
        tooltip: {
            valueDecimals: 2
        }
    }]
});

请建议我如何实现它我已在A / B / C中映射D

select *
from A
  left join B
    on a.d = b.d
  left Join C
    on c.d = b.d

请建议。

1 个答案:

答案 0 :(得分:0)

<强>更新

我已根据您的配置完成了一些测试,这是对我有用的HQL查询:

select distinct a 
from A a, B b, C c 
where ((a.d=b.d) or (a.d is null) or (b.d is null)) 
   and ((b.d=c.d) or (b.d is null) or (c.d is null))

它支持D的加入,并且LEFT JOIN友好。