db2 sql查询中的意外标记

时间:2013-11-07 15:55:21

标签: sql hibernate db2 entity

这是我的疑问:

    "SELECT t FROM LeerkrachtEntity t WHERE t = (SELECT l.leerkracht FROM LesEntity l WHERE l.id = :lesId)  AND t IN (SELECT k.teachers FROM KlasEntity k WHERE k.id = :klasId) AND t.id = :leerkrachtId"

这就是hibernate的作用:

    Hibernate: 
/* SELECT
    t 
FROM
    LeerkrachtEntity t 
WHERE
    t = (
        SELECT
            l.leerkracht 
        FROM
            LesEntity l 
        WHERE
            l.id = :lesId
    )  
    AND t IN (
        SELECT
            k.teachers 
        FROM
            KlasEntity k 
        WHERE
            k.id = :klasId
    ) 
    AND t.id = :leerkrachtId */ select
        leerkracht0_.person_id as person_i1_12_,
        leerkracht0_1_.email as email2_12_,
        leerkracht0_1_.familienaam as familien3_12_,
        leerkracht0_1_.voornaam as voornaam4_12_ 
    from
        leerkracht leerkracht0_ 
    inner join
        person leerkracht0_1_ 
            on leerkracht0_.person_id=leerkracht0_1_.person_id 
    where
        leerkracht0_.person_id=(
            select
                lesentity1_.person_id 
            from
                les lesentity1_,
                leerkracht leerkracht2_ 
            inner join
                person leerkracht2_1_ 
                    on leerkracht2_.person_id=leerkracht2_1_.person_id 
            where
                lesentity1_.person_id=leerkracht2_.person_id 
                and lesentity1_.les_id=?
        ) 
        and (
            leerkracht0_.person_id in (
                select
                    . 
                from
                    klas klasentity3_,
                    leerkracht_klas teachers4_,
                    leerkracht leerkracht5_ 
                inner join
                    person leerkracht5_1_ 
                        on leerkracht5_.person_id=leerkracht5_1_.person_id 
                where
                    klasentity3_.klas_id=teachers4_.klas_id 
                    and teachers4_.person_id=leerkracht5_.person_id 
                    and klasentity3_.klas_id=?
            )
        ) 
        and leerkracht0_.person_id=?

我收到以下错误:

    16:48:27.475 ERROR o.h.e.jdbc.spi.SqlExceptionHelper - unexpected token: KLAS required: )

我正在尝试获取leerkrachtEntity,其中数据库'lesId'和'klasId'已连接。 请帮我。我不知道出了什么问题。


当我使用这部分查询时,一切正常。

       "SELECT t FROM LeerkrachtEntity t WHERE t = (SELECT l.leerkracht FROM LesEntity l WHERE l.id = :lesId)  AND t.id = :leerkrachtId"

这里出错:

    t IN (SELECT k.teachers FROM KlasEntity k WHERE k.id = :klasId) AND 

1 个答案:

答案 0 :(得分:0)

您是否有一个名为KLAS的对象,或者应该是KlasEntity