-->
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: SQL union is not working in SQL query for property attribute
PostPosted: Thu Oct 18, 2007 2:23 am 
Newbie

Joined: Mon Sep 18, 2006 8:44 am
Posts: 2
Hibernate version:
3.2.5.ga

Mapping documents:
Code:
<class name="Reference" ..>
    <property name="objectId" ../>
  <property name="title" formula="(select obj1.title from Table1 obj1 where obj1.Id=objectId
union
select obj2.title from Table2 obj2 where obj2.Id=objectId)"/>
</class>


Name and version of the database:
PostgreSQL 8.1

Generated SQL:
Code:
select
  ...,
  objectId,
   (select obj1.title from Table1 obj1 where obj1.Id=objectId
reference0_.union
select obj2.title from Table2 obj2 where obj2.Id=objectId) from ReferenceTable reference0_
...


Hello. Sorry for my english.

I've found following problem. I need, that my persistent entity Reference
would have calculated field "title". It is a title of object, that my
Reference entity refers to. My Reference entity also would have identifier
of this object. This object can be an entity of classes in the different
classes hierarhies. I want to calculate title field of Reference as object
title. So, I'm writing this mapping (see "Mapping documents").
I know, that this query in my case will return only one value.
So, When hibernate is trying to load my Reference entity, it constructs
wrong SQL query (see "Generated SQL").

I think it is a bug. Could anybody comment my situation?

Sincerely, Vadim Gindin


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.