gpt4 book ai didi

java - 玩Ebean .orderBy()坏了?将字符替换为 "$ "

转载 作者:太空宇宙 更新时间:2023-11-04 13:46:30 25 4
gpt4 key购买 nike

以下Ebean查找

String join = "trackToArtists.artist.artistToTags.tag.stationToTags.station";
return find
.where()
.eq(join, station)
.ge(join + ".energyMin", settings.energyMin)
.le(join + ".energyMax", settings.energyMax)
.ge(join + ".livenessMin", settings.livenessMin)
.le(join + ".livenessMax", settings.livenessMax)
.ge(join + ".tempoMin", settings.tempoMin)
.le(join + ".tempoMax", settings.tempoMax)
.ge(join + ".acousticnessMin", settings.acousticnessMin)
.le(join + ".acousticnessMax", settings.acousticnessMax)
.ge(join + ".danceMin", settings.danceMin)
.le(join + ".danceMax", settings.danceMax)
.orderBy("trackToArtists.artist.artistToTags.score DESC")
.setMaxRows(Util.TopN)
.findList();

似乎生成了不正确的 SQL 查询,特别是 ORDER_BY:

Syntax error in SQL statement "SELECT DISTINCT T0.ID ... AND U6.DANCE_MAX <= ?  ORDER BY $  RACKTOARTISTS[*].ARTIST.ARTISTTOTAGS SCORE DESC 

完整 SQL(由 Ebean 生成):

SELECT DISTINCT T0.ID C0, T0.ACTIVE C1, T0.NAME C2, T0.MD5 C3, T0.EN_TRACK_ID C4, T0.EN_SONG_ID C5, T0.LASTR C6, T0.LAST_LISTENER_COUNT C7, T0.LAST_PLAY_COUNT C8, T0.LAST_PLAY_COUNT_NORM C9, T0.MB_ID C10, T0.EN_ANALYZER_VERSION C11, T0.DURATION C12, T0.EN_DANCEABILITY C13, T0.ENNERGY C14, T0.EN_KEY C15, T0.EN_KEY_CONFIDENCE C16, T0.LOUDNESS C17, T0.LOUDNESS_NORM C18, T0.EN_MODE C19, T0.EN_MODE_CONFIDENCE C20, T0.EN_TEMPO C21, T0.EN_TEMPO_CONFIDENCE C22, T0.EN_TEMPO_NORM C23, T0.EN_TIME_SIGNATURE C24, T0.EN_TIME_SIGNATURE_CONFIDENCE C25, T0.EN_SONG_HOTNESS C26, T0.EN_SPEECHINESS C27, T0.EN_ACOUSTICNESS C28, T0.EN_LIVENESS C29, T0.ENVALENCE C30, T0.LAST_ID C31, T0.LAST_URL C32 FROM TRACK T0 JOIN TRACK_TO_ARTIST U1 ON U1.TRACK_ID = T0.ID  JOIN ARTIST U2 ON U2.ID = U1.ARTIST_ID  JOIN ARTIST_TO_TAG U3 ON U3.ARTIST_ID = U2.ID  JOIN TAG U4 ON U4.ID = U3.TAG_ID  JOIN STATION_TO_TAG U5 ON U5.TAG_ID = U4.ID  JOIN STATION U6 ON U6.ID = U5.STATION_ID  WHERE U5.STATION_ID = ?  AND U6.ENERGY_MIN >= ?  AND U6.ENERGY_MAX <= ?  AND U6.LIVENESS_MIN >= ?  AND U6.LIVENESS_MAX <= ?  AND U6.TEMPO_MIN >= ?  AND U6.TEMPO_MAX <= ?  AND U6.ACOUSTICNESS_MIN >= ?  AND U6.ACOUSTICNESS_MAX <= ?  AND U6.DANCE_MIN >= ?  AND U6.DANCE_MAX <= ?  ORDER BY $  RACKTOARTISTS[*].ARTIST.ARTISTTOTAGS SCORE DESC LIMIT 11

我什至不知道是什么导致它将“trackToArtists”解释为“$ RACKTOARTISTS”。

最佳答案

尝试这样做:

find.fetch("trackToArtists.artist.artistToTags")
.where()
.eq(join, station)
.ge(join + ".energyMin", settings.energyMin)
.le(join + ".energyMax", settings.energyMax)
.ge(join + ".livenessMin", settings.livenessMin)
.le(join + ".livenessMax", settings.livenessMax)
.ge(join + ".tempoMin", settings.tempoMin)
.le(join + ".tempoMax", settings.tempoMax)
.ge(join + ".acousticnessMin", settings.acousticnessMin)
.le(join + ".acousticnessMax", settings.acousticnessMax)
.ge(join + ".danceMin", settings.danceMin)
.le(join + ".danceMax", settings.danceMax)
.orderBy("trackToArtists.artist.artistToTags.score DESC")
.setMaxRows(Util.TopN)
.findList();

关于java - 玩Ebean .orderBy()坏了?将字符替换为 "$ ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30785593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com