Java HQL org.hsqldb.HsqlException: user lacks privilege or object not found
I am using Spring 3 with Hibernate 3. I am using DAO design pattern and using HQL to query the database. However, when looking for data that does not exist for a field, I get the following exception:
org.hsqldb.HsqlException: user lacks privilege or object not found: ADDRESS2
I am using Liquidbase to manage a database XML schema that creates tables. Below is a sample code:
@Entity
@Table(name = "message")
public class Message() {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(length = 100, nullable = false)
private String address;
public Message() {
}
// getters and setters
}
The DAO uses the following HQL:
getHibernateTemplate().find("FROM Message m WHERE m.address = address2");
The following properties are set:
jdbc.driverClassName=org.hsqldb.jdbc.JDBCDriver
jdbc.url=jdbc:hsqldb:mem:testdb'shutdown=true
jdbc.username=sa
jdbc.password=
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=validate
I cannot find a solution. I can successfully insert a record and also use the same HQL query to find objects with stored actual values, but the problem is finding values that don't exist.
source to share
FROM Message m WHERE m.address = address2
This query looks for messages whose fields are address
equal to their field address2
. But messages don't have a margin address2
. If you want to find all messages whose field address
is "address2", query
FROM Message m WHERE m.address = 'address2'
source to share