2016-07-22 53 views
0

我收到以下錯誤:錯誤:關係「project文件」不Activejdbc存在即使表存在

org.javalite.activejdbc.DBException: org.postgresql.util.PSQLException: ERROR: relation "projectfile" does not exist 
    Position: 25, query: SELECT customer.id FROM projectfile LEFT JOIN project ON projectfile.project_id=project.id LEFT JOIN customer ON project.customer_id=customer.id WHERE (project.activity=6 OR project.activity=1) AND project.workflowmaxstatus='finish' AND project.workflowminstatus='finish' AND projectfile.type=1 AND projectfile.filename like '%.docx' AND project.startdate > NOW() - interval '2 months' GROUP BY customer.id 

這似乎抱怨表,但我雙重檢查和表是那裏的公共架構。我看到有關這個主題的不同線程已經打開,但我找不到解決方案。

哪個是主要原因?

謝謝。

+0

您可以發佈一個查詢用於創建此表嗎? – ipolevoy

+0

下面是該查詢:查詢字符串= 「SELECT customer.id FROM project文件」 + 「LEFT JOIN項目ON projectfile.project_id = project.id」 \t \t \t \t \t +「LEFT JOIN客戶ON project.customer_id = customer.id 「+」 WHERE(project.activity = 6 OR project.activity = 1) 「 \t \t \t \t \t +」 AND project.workflowmaxstatus = '完成' 「+」 和project.workflowminstatus = '結束'「 \t \t \t \t \t +「AND projectfile.type = 1 AND projectfile.filename like'%。」 + format +「'AND project.startdate> NOW() - interval'」+ month +「months'GROUP BY customer.id」; customer_findBySQL(query); \t \t \t LazyList customerList = Customer.findBySQL(query); – csm86

回答

0

問題是,您從模型運行自由格式查詢:Customer.findBySQL(query)。方法Model#findBySQL確實有侷限性:

Ensure that the query returns all columns associated with this model so that the resulting models could hydrate themselves properly....

你根本不能在模型中使用這樣的查詢。你在這種情況下需要的是Base#findAllDB#findAll

tx

相關問題