0

这是我的查询:

    "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: 
/* 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: )

我正在尝试获取连接数据库“lesId”和“klasId”的 leerkrachtEntity。请帮我。我不知道出了什么问题。


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

       "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 
4

1 回答 1

0

你有一个对象叫KLAS还是应该叫的对象KlasEntity

于 2013-11-07T17:20:50.907 回答