-->
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.  [ 10 posts ] 
Author Message
 Post subject: many-to-one formula with @Formula??
PostPosted: Thu Dec 29, 2005 5:12 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
I am trying to find the equivalent mapping for the following:

Mapping:
Code:
    <many-to-one name="offerPrice"
                 class="pipetracker.model.price.OfferPrice"
                 formula="( select v_pipe_offerprice.offerprice_fk
                              from v_pipe_offerprice
                              where v_pipe_offerprice.id = id )"/>


The following is not working for me:

Code:
    @ManyToOne
    @Formula(value="( select v_pipe_offerprice.offerprice_fk from v_pipe_offerprice where v_pipe_offerprice.id = id )")
    public OfferPrice getOfferPrice() { return offerPrice; }


I get the following error:

Code:
[JDBCExceptionReporter] ERROR: column pipe0_.offerprice_offerprice_fk does not exist

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


Top
 Profile  
 
 Post subject: Is a @ManyToOne supported for use with @Formula?
PostPosted: Wed Jan 04, 2006 8:49 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
I am still looking for a way to get this to work for me. Let me explain what I am doing more clearly. I am migrating an appliction with about 60+ entities from Hibernate 3.0 with mapping files to 3.1 using annotations. I am stuck trying to do the equivalent to the following:

Code:
  <class name="Pipe" table="t_pipe">
...
    <many-to-one name="offerPrice"
                 class="pipetracker.model.price.OfferPrice"
                 formula="( select v_pipe_offerprice.offerprice_fk
                              from v_pipe_offerprice
                              where v_pipe_offerprice.id = id )"/>
...
</class>


This works fine for me in both versions of hibernate, but I cannot seem for get the syntax correct for the annotation based mapping.

Code:
    @ManyToOne
    @Formula(value="( select v_pipe_offerprice.offerprice_fk from v_pipe_offerprice where v_pipe_offerprice.id = id )")
    public OfferPrice getOfferPrice() { return offerPrice; }


This is not being considered a formula. The sql inludes a select for the field "pipe.offerprice_id" which does not exist because this is just virtual relationship that is being calculated from a view. I display lists of pipe that have an offerprice based on half a dozen or so properties and I would lke this to be calculated once by the database.

When mapped as in the mapping field my queries are simple:

Code:
from Pipe p where p.offerprice.price > 63.25


or

Code:
from Pipe p where p.offerprice.usr.name = 'jason'


and I can also look up the price in code

Code:
pipe.getOfferPrice().getUsr().getName();


Is this suppported by annotations currently?

If this is not supported can you please suggest an alternate design stragety?

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 5:57 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The recommended strategy is to open a JIRA issue and provide a patch :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: JIRA issue opened
PostPosted: Thu Jan 05, 2006 1:47 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
Thank you for your reply Emmanuel. I added a JIRA issue and I am considering if my experience and available time will permit me to provide a patch. Do you think this will require trivial or involved effort to resolve this issue?

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 1:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is not super easy, but reasonably doable.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 09, 2006 9:58 am 
Newbie

Joined: Wed Mar 08, 2006 9:10 pm
Posts: 7
Any news on this?


Top
 Profile  
 
 Post subject: many-to-one formula with @Formula??
PostPosted: Thu Mar 09, 2006 11:54 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
I considered making a patch, but I do not currently have the resources available. I would also like to know the status of this open item?

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 12, 2006 5:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is not on my top priority list for now, but patch is still welcome

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: many-to-one formula with @Formula??
PostPosted: Fri Feb 20, 2015 12:21 pm 
Newbie

Joined: Fri Feb 20, 2015 12:14 pm
Posts: 6
Hi Team,

What is the link to the JIRA issue. I am hitting the same issue and am trying to come up with some kind of a patch. However, I would like to look at the work to date, and get pointed in the right direction.
Thanks,
Jeff


Top
 Profile  
 
 Post subject: Re: many-to-one formula with @Formula??
PostPosted: Fri Feb 20, 2015 1:45 pm 
Newbie

Joined: Wed Mar 08, 2006 9:10 pm
Posts: 7
I think this is the issue: https://hibernate.atlassian.net/browse/HHH-4382


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