-->
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.  [ 4 posts ] 
Author Message
 Post subject: property formula issue: adding unwanted alias
PostPosted: Tue Oct 25, 2005 4:30 pm 
Beginner
Beginner

Joined: Tue Jan 06, 2004 4:51 pm
Posts: 48
Hi,

I am new to 3.0.4, and the formula attribute/nested element seems really handy. Here is how I'm trying to use it:

Hibernate version:
3.0.4

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.cc.rewards.InterviewerReward" table="supervisor_reward" mutable="true" polymorphism="explicit" lazy="true">
<composite-id>
<key-many-to-one name="employee" class="com.cc.rewards.RewardsEmployee" column="emp_id"/>
<key-property name="date" type="date" column="date"/>
</composite-id>

formula="get_total_sr_points(interviewer_reward)"/>

</class>
</hibernate-mapping>

Name and version of the database you are using:
PostgreSQL 8.0.4

The generated SQL (show_sql=true):
select interviewe0_.emp_id as emp1_, interviewe0_.date as date, get_total_ir_points(interviewe0_.interviewer_reward) as formula0_ from interviewer_reward interviewe0_

As you can see, for the formula, it has added the alias interviewe0_. in front of my interviewer_reward record, which causes an error as there is no such column interviewer_reward. How can I prevent this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 12:54 pm 
Beginner
Beginner

Joined: Tue Jan 06, 2004 4:51 pm
Posts: 48
does anyone have any ideas at all?


Top
 Profile  
 
 Post subject: Unwanted table qualifier
PostPosted: Thu Nov 03, 2005 11:04 am 
Newbie

Joined: Thu Nov 03, 2005 10:27 am
Posts: 2
I have a very similar problem (if not the exact same one)

When using a SQL statement with a subquery in the many-to-one formula property, the parser will add the table qualifier to one of the expressions of the where clause.

For example:


formula="(select * from (select a.pk_id from table1 a where a.fk_id=fk_id order by a.pk_id desc) where rownum = 1)"

Which results in:

...(select * from (select a.pk_id from table1 a where a.fk_id=table20_.cat_id order by a.pk_id desc) where rownum = 1) ...


When I manually remove hibernate's alias in Oracle, the query works fine.

Does anyone else found any workarounds?

I want to think that perhaps I'm doing something wrong rather than there being a bug in hibernate. I'd have a hard time believing that no one else is using formula this way.




Other references of the same problem:
http://forum.hibernate.org/viewtopic.php?t=949494

Here's a workaround, although kinda vague:
http://thebogles.com/blog/2005/08/hibernate-formula-properties-bug-and/


Top
 Profile  
 
 Post subject: Formula issue
PostPosted: Mon Nov 28, 2005 3:12 pm 
Newbie

Joined: Thu Nov 18, 2004 4:03 pm
Posts: 7
Location: Pittsburgh,pa
I had some success using this

/** The getter method for this Item's type
*
* @hibernate.property
* formula="(select count(*) from ttemplateelements te where te.templateelementid IN (select pe.copiedfrom_portfolioelementid from tPortfolioelements pe where pe.itemid=itemid and pe.copiedfrom_portfolioelementid IS NOT NULL) and te.allow_edit='no' )"
*/


hope that helps


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.