Hi
This one is killing me so I really need some help.
Developing a web app using Hibernate 3 and SQL Server 2000 and having setup some mappings there is at least one that is not working.
The db table db_salesProductType
having columns:
salesProductTypeId (Bigint)
salesProductTypeName (varchar)
active (char)
SalesProductType.hbm.xmlCode:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="dbo" package="com.teliasonera.relo.domain">
<class name="SalesProductType" table="tbl_salesProductType">
<id name="id" column="salesProductTypeId" type="Long"/>
<property name="displayValue" column="salesProductTypeName" not-null="true"/>
<property name="active" column="active" not-null="true"/>
</class>
</hibernate-mapping>
SalesProductType.java (with proper setters and getters for given attributes, but the are left out)
Code:
...
private String displayValue;
private Long id;
private String active;
...
SalesProductTypeHibDAOCode:
...
public List<SalesProductType> getAll() {
Query q = getSession().createQuery("FROM SalesProductType s WHERE s.active = :pActive ORDER BY s.displayValue ASC");
log.debug("Query: " + q.getQueryString());
q.setString("pActive", "y");
List<SalesProductType> salesProductTypes = q.list();
log.debug("[getAll] returning list of size " + salesProductTypes.size());
return salesProductTypes;
}
...
from
hibernate.cfg.xmlCode:
<mapping resource="com/company/app/dao/hibernate/SalesProductType.hbm.xml"/>
And the exception thrown when creating the query:
org.hibernate.QueryException: in expected: s [FROM SalesProductType s WHERE s.active = :pActive ORDER BY s.displayValue ASC]
Another thing I should mention is that in this table I don't have any identity column, the 'id' attribute in the mapping file is an ordinary bigint column, wonder if this can cause the problem? The code creating the query is copied from another class and that mapping isworking fine, the only difference - at least what I've noticed this far - is this circumstance, since the other mapping is using a generator='identity' attribute
Anyone???
Forgot to mention, since I'm quite new to Hibernate I wonder if all mappings is performed during startup (using JBoss AS 4.3), I can see some mappings is performed during startup, but I also know that there are some Util classes configured in web.xml to load at startup (as you notice I'm not the man behind all development of this app, but rther I'm trying to extend it)
/R