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.

+3


source to share


4 answers


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'

      

+2


source


try:



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

      

0


source


Check your database url:

You may need to provide the full path to the database

For example, JDBC: HSQLDB: file C: /Users/10617136/dev/hsqldb-2.3.2/hsqldb/bin/test

0


source


I feel wired. After I changed my field name from profileImage

to image

, i.e. Making everything lowercase solves the problem.

0


source







All Articles