0

I am getting the following error:

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

It seems to complain about a table but I double checked and the table is there in the public schema. I saw there are differet threads open regarding this topic but I couldn't find the solution.

Which is the main cause?

Thanks.

Cosmin D
  • 639
  • 1
  • 11
  • 24
  • Can you post a query used to create this table? – ipolevoy Jul 22 '16 at 14:01
  • Here is the query: String 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 '%." + format + "' AND project.startdate > NOW() - interval '" + month + " months' GROUP BY customer.id"; LazyList customerList = Customer.findBySQL(query); – Cosmin D Jul 22 '16 at 18:14

1 Answers1

0

The problem is that you running a free form query from a model: Customer.findBySQL(query). The method Model#findBySQL does have limitations:

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

You simply cannot use such query from a model. What you need in this case is Base#findAll or DB#findAll.

tx

ipolevoy
  • 5,432
  • 2
  • 31
  • 46