Numeric parameters for foreign keys in an HQL expression

These both work:

 OrmExecuteQuery("FROM Person WHERE Company = 1",[]);
 OrmExecuteQuery("FROM Person WHERE companyID = 1",[]);

"Company" is the name of the property and refers to the "Company" object, while "companyID" is the column name (FK associated with auto-inc PK).

However, what I'm trying to do is more complicated - it includes joins, and this requires the use of an alias.

So, I am updating these two queries with an alias ...

 OrmExecuteQuery("FROM Person AS BaseEntity WHERE BaseEntity.Company = 1",[]);
 OrmExecuteQuery("FROM Person AS BaseEntity WHERE BaseEntity.companyID = 1",[]);

The first one still works, the second causes an error:

An error occurred while executing a Hibernate request.

org.hibernate.QueryException: Failed to resolve property: companyID of: Person

I have no idea why both versions with an uninstalled version work.

, , , ( )...

 OrmExecuteQuery("FROM Person WHERE Company = ?",[1]);
 OrmExecuteQuery("FROM Person WHERE companyID = ?",[1]);
 OrmExecuteQuery("FROM Person AS BaseEntity WHERE BaseEntity.Company = ?",[1]);
 OrmExecuteQuery("FROM Person AS BaseEntity WHERE BaseEntity.companyID = ?",[1]);

... .

, .

:

class java.lang.String .

, , CF .

- CF/Hibernate, : java.lang.NullPointerException - .

Hibernate?

+3
1

, companyID Company, CompanyID , ..

OrmExecuteQuery("FROM Person AS BaseEntity WHERE BaseEntity.Company.companyID = ?",[1]);

:

OrmExecuteQuery("FROM Person WHERE Company.companyID = ?",[1]);
+2

All Articles