-->
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.  [ 2 posts ] 
Author Message
 Post subject: U a Guru? How to use formula with dynamic values?
PostPosted: Fri Jul 28, 2006 12:58 pm 
Regular
Regular

Joined: Sat Jan 22, 2005 6:57 pm
Posts: 50
Location: Chicago
Say you have an xml mapping with a property element that tries to define a formula like so:

Code:
<hibernate-mapping package="com.foo.mc.data.imsfield">
   <class name="ImsField" table="IMS_FIELD" schema="DEMO">

      <id name="ID" column="ID" type="long">
         <generator class="assigned" />
      </id>

      <property name="tableName" type="string">
         <column name="TABLE_NAME" />
      </property>
      
      <property name="fieldName" type="string">
         <column name="FIELD_TYPE" />
      </property>
      
      <property name="availableNames" formula="(select fieldName from tableName)"/>
   </class>
</hibernate-mapping>


The above xml does not work, but what we are trying to do is substitute in the formula the property value for fieldName in the formula as well as property value for tableName in the formula.

So if, for example, the above mapping reflected these values:

Code:
id = 4
tableName = bigtable
fieldName = foo


then the property formula would get translated to:

Code:
select foo from bigtable


Is this possible? And if so, how do we define our formula to grab these elements?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 28, 2006 1:00 pm 
Regular
Regular

Joined: Sat Jan 22, 2005 6:57 pm
Posts: 50
Location: Chicago
Two more clarifications:

1.) I should also mention that the formula should return an array of 1 or more string results. It will not always be a single element being returned. I think this can be accomodated by merely making the pojo have a String[] property with the appropriate getters/setters? Or a set?

2.) Is it possible to put a standard sql statement in the formula? One that is not mapped to a Hibernate Mapping but will return a java.lang value like string or array of strings?


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