-->
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.  [ 2 posts ] 
Author Message
 Post subject: Need help! Could not execute query with select join
PostPosted: Fri Mar 27, 2009 5:36 am 
Newbie

Joined: Wed Aug 27, 2008 11:10 am
Posts: 2
Hello all

I have big problem :(

I can't run HQL with many-to-many relationship

I have 3table: Article - vw_RelationshipCategories - Category

Article - [man to many] - Category

and 2 object: Article & Category

1. Article

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
  <class name="Article" table="vw_articles">
    <id name="ID" type="System.Int32" column="PostId">
      <generator class="assigned"/>
    </id>
    <property name="CategoryId" column="CategoryId" type="System.Int32" />
    <property name="Title" column="Title" type="System.String" />
    <property name="ClearTitle" column="ClearTitle" type="System.String" />
    <property name="Description" column="Description" type="System.String" />
   
    <bag name="Categories" table="vw_relationshipcategories" cascade="none">
      <key column="PostId" />
      <many-to-many column="CategoryId" class="Category" />
    </bag>
  </class>
</hibernate-mapping>


2. Category

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
   <class name="Category" table="vw_categories">
      <id name="ID" type="System.Int32" column="CategoryId">
         <generator class="assigned"/>
      </id>
    <property name="Name" column="name" type="System.String" />
    <property name="Slug" column="slug" type="System.String" />
    <property name="Description" column="description" type="System.String" />
   </class>
</hibernate-mapping>


When I run a HQL:

"from Article a join a.Categories c where c.Slug='bank1x'" <= No result value -> not have bug

"from Article a join a.Categories c where c.Slug='bank'" <= Have error "Could not execute query"

I don't know why have bug :(

Help me!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 27, 2009 7:17 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Looks fine for me. Is there a inner exception in the query exception ?

_________________
--Wolfgang


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

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.