Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java HQL org.hsqldb.HsqlException: user lacks privilege or object not found

I am using Spring 3 with Hibernate 3. I am using the DAO design pattern and using HQL to query the database. However, when searching 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 the database XML schema that creates the tables. Below is the 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 following HQL is used from the DAO:

 getHibernateTemplate().find("FROM Message m WHERE m.address = address2");

The following properties are being 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 actual values that have been saved, but the problem is with finding values that don't exist.

like image 511
user Avatar asked Nov 22 '25 18:11

user


1 Answers

FROM Message m WHERE m.address = address2

This query looks for messages whoses address field is equal to their address2 field. But messages don't have an address2 field. If your intention is to find all messages whose address field has the value "address2", then the query is

FROM Message m WHERE m.address = 'address2'
like image 184
JB Nizet Avatar answered Nov 25 '25 10:11

JB Nizet