-->
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: missing FROM-clause entry for table
PostPosted: Mon Oct 29, 2007 4:27 pm 
Newbie

Joined: Mon Oct 22, 2007 8:27 pm
Posts: 7
Hi!

When I use a <properties> element to do a multi-column unique constraint, I get the error "missing FROM-clause entry for table" if I try to access one of my association:

Code:
<hibernate-mapping>
...
<properties name="dataset_contents_dataset_id_key" unique="true">
  <many-to-one name="dataset" class="Dataset" fetch="select">
    <column name="dataset_id" not-null="true" />
  </many-to-one>
  <many-to-one name="usrDatatype" class="UsrDatatype" fetch="select">
    <column name="type_id" not-null="true" />
  </many-to-one>
</properties>
...
</hibernate-mapping>


The result is:

Code:
select
        this_.id as id3_0_,
        this_.version as version3_0_,
        this_.dataset_id as dataset3_3_0_,
        this_.type_id as type4_3_0_,
        this_.tag_lo as tag5_3_0_,
        this_.tag_hi as tag6_3_0_
    from
        cmd.dataset_contents this_
    where
        this_.dataset_id=?
        and usrdatatyp1_.type_name=?


SQL Error: 0, SQLState: 42P01
ERROR: missing FROM-clause entry for table "usrdatatyp1_"

As you can see there is no "inner join" statement added after the from!

But without <properties> I get:

Code:
select
        this_.id as id3_1_,
        this_.version as version3_1_,
        this_.dataset_id as dataset3_3_1_,
        this_.type_id as type4_3_1_,
        this_.tag_lo as tag5_3_1_,
        this_.tag_hi as tag6_3_1_,
        usrdatatyp1_.id as id30_0_,
        usrdatatyp1_.version as version30_0_,
        usrdatatyp1_.type_name as type3_30_0_
    from
        cmd.dataset_contents this_
    inner join
        cmd.usr_datatype usrdatatyp1_
            on this_.type_id=usrdatatyp1_.id
    where
        this_.dataset_id=?
        and usrdatatyp1_.type_name=?


Is this a bug or an error in the mapping?

I also tried changing the fetch option of "usrDatatype" to "join" instead of "select" to force the inner join but the alias generated by hibernate was different and I got the same error:

Code:
select
        this_.id as id3_1_,
        this_.version as version3_1_,
        this_.dataset_id as dataset3_3_1_,
        this_.type_id as type4_3_1_,
        this_.tag_lo as tag5_3_1_,
        this_.tag_hi as tag6_3_1_,
        usrdatatyp3_.id as id30_0_,
        usrdatatyp3_.version as version30_0_,
        usrdatatyp3_.type_name as type3_30_0_
    from
        cmd.dataset_contents this_
    inner join
        cmd.usr_datatype usrdatatyp3_
            on this_.type_id=usrdatatyp3_.id
    where
        this_.dataset_id=?
        and usrdatatyp1_.type_name=?


I'm using the latest hibernate version (3.2.5 GA) with PostgreSQL...

Thanks

Christian


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.