-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: org.hibernate.QueryException: in expected
PostPosted: Mon Jan 10, 2011 4:17 pm 
Newbie

Joined: Tue May 12, 2009 4:46 am
Posts: 2
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.xml
Code:

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;
...


SalesProductTypeHibDAO
Code:
...
   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.xml
Code:
<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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.