我在注释块中有一个长字符串,就像这个一样(参见query
属性):
/**
* @Table(name="messages")
* @Entity
* @NamedNativeQueries({
* @NamedNativeQuery(
* name = "searchMessages",
* resultClass= "__CLASS__",
* query = "SELECT * FROM message WHERE id IN (SELECT post_id FROM (SELECT m.post_id, COUNT(*) AS words FROM phpbb_search_wordmatch m INNER JOIN phpbb_search_wordlist w ON w.id = m.word_id WHERE blah blah blah blah ...."
* )
* })
*/
class Message {
...
我希望将其划分为多行,以便更具可读性。
是否可以在多行中断查询字符串?
答案 0 :(得分:8)
我自己就找到了它:
/**
* @Table(name="messages")
* @Entity
* @NamedNativeQueries({
* @NamedNativeQuery(
* name = "searchMessages",
* resultClass= "__CLASS__",
* query = "SELECT * FROM message WHERE id IN (
SELECT post_id FROM (
SELECT m.post_id, COUNT(*) AS words
FROM phpbb_search_wordmatch m
INNER JOIN phpbb_search_wordlist w ON w.id = m.word_id
WHERE blah blah blah blah ...."
* )
* })
*/
class Message {
...
这可以按预期工作。