Announcement Announcement Module
Collapse
No announcement yet.
help with the named query Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • help with the named query

    I defined a named query in my .bhm.xml file

    <sql-query name="getFlexibleAttributes">
    <return alias="attribute" class="com.xxx.app.dal.AttributeTO"/>
    <![CDATA[SELECT fd.LABEL as {attribute.attributeName}, fn.ATTRIBUTE_VALUE as
    {attribute.attributeValue}
    FROM TABLE_PART_NUM pn, TABLE_FA_PART_NUM fn, TABLE_FLEX_DEFN fd
    WHERE fn.FA_PART_NUM2PART_NUM = pn.OBJID and
    fd.ATTRIBUTE_NAME = fn.ATTRIBUTE_NAME and
    pn.PART_NUMBER = artNumber]]>
    </sql-query>

    What I'm trying to do is to pull data from three different tables into object AttributeTO. There is no table for this object.

    When I ran my app, I got the following error

    [Jan-19 12:19:37][ERROR][com.xxx.app.dao.logic.RatePlanDaoImpl] Unknown entity class: com.xxx.app.dal.AttributeTO; nested exception is net.sf.hibernate.MappingException: Unknown entity class: com.xxx.app.dal.AttributeTO

    Any clue what caused the problem? Thanks.

  • #2
    If you can express yur query using HQL, it is possible to use session.find / session.iterate. For more details take a look at 9.3.1. Scalar queries.
    Otherwise, you need either to provide a mapping for your class or use JDBC.
    HTH

    Comment


    • #3
      AttributeTO is a POJO, no mapping table. How do I define the mapping for this calss? If I can't define a mapping, can I express the query using HQL?

      Thanks.

      Comment


      • #4
        You can't use Hibernate queries on objects that are not managed by Hibernate - that is objects that don't have a mapping. For information on how to define the mapping you should read the Hibernate Reference Guide which is pretty extensive.

        Rob

        Comment

        Working...
        X