Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: many-to-one formula usage
PostPosted: Sun Oct 30, 2005 9:15 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 6:33 pm
Posts: 29
Location: Vancouver, BC, Canada
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1rc2

I am looking for an example of a non-trivial usage of <formula> in a <many-to-one> mapping. The examples in the doc or the hibernate test cases are just constants.

In the formula I need to to use a combination of joins and calls to PL/SQL functions, but that is not possible because hibernate qualifies all my strings with the table name. Example:

Code:
<many-to-one name="primaryKeyColumnDefinition"
        class="bootdb.ColumnDefinition">
        <formula >
SELECT pk_column.impo_id
from   key_constraint        primary_key
      ,key_constraint_column pk_concol
      ,column_definition     pk_column
WHERE  primary_key.impo_id_reldf = impo_id
AND    pk_concol.impo_id_kcon = primary_key.impo_id
AND    pk_concol.impo_id_coldf = pk_column.impo_id
        </formula>
        </many-to-one>


renders to something like:

Code:
SELECT pk_column.impo_id
from   relationde0_.key_constraint        relationde0_.primary_key
      ,relationde0_.key_constraint_column relationde0_.pk_concol
      ,relationde0_.column_definition     relationde0_.pk_column
WHERE  primary_key.impo_id_reldf = relationde0_.impo_id
AND    pk_concol.impo_id_kcon = primary_key.impo_id
AND    pk_concol.impo_id_coldf = pk_column.impo_id
         as formula0_ from RELATION_DEFINITION relationde0_ where (relationde0_.NAME='foo')


How can I convince hibernate not to qualify the table names? I tried all kinds of quotes, and it did not work.

Thanks,

Calin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 30, 2005 9:40 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
I don't know your database, but if you use PL/SQL it is oracle, probably

try define view in database and then formula is 'select ... from viewName'

hibernate will add table name, but it isn't important more


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 30, 2005 11:58 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 6:33 pm
Posts: 29
Location: Vancouver, BC, Canada
Hi,

It is Oracle indeed. And what you say would work, but I can not modify the DB Schema, so I am looking for a solution on the Hibernate side...

Thanks,

Calin


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 31, 2005 5:14 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
try change dialect and add your pl/sql functions


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.