-->
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: filter using schema name as parameter
PostPosted: Wed May 21, 2008 3:09 pm 
Newbie

Joined: Fri Feb 20, 2004 12:23 pm
Posts: 10
I am trying to construct a mapping using a filter with a parameter using a collection, AND a schema name. The collection works fine, but I can't parameterize the schema name.

Code:
<class name="Product" table="product">
   <id name="serialNumber" column="product_serial_number"/>
   <set name="parts">
      <key column name="product_serial_number" not-null="true"/>
      <one-to-many class="Part"/>
      <filter name="partFilter" condition="part_type in (select pg.part_type from :schema_name.part_group as pg where pg.group in(:groups))"/>
   </set>
</class>

<filter-def name="partFilter">
   <filter-param name="schema_name" type="string"/>
   <filter-param name="groups" type="string"/>
</filter-def>

Unsurprisingly, this will not work, as the :schema_name can't be declared as a parameter. I get the following error:

Code:
java.lang.InternalError: Unable to locate type for filter parameter
   org.hibernate.impl.SessionImpl.getFilterParameterType(SessionImpl.java:1065)


Is there another way for me to filter my collections data such that the schema name is set at runtime?

thanks!


Top
 Profile  
 
 Post subject: Re: filter using schema name as parameter
PostPosted: Wed Jun 04, 2008 10:46 am 
Newbie

Joined: Wed Jun 04, 2008 10:02 am
Posts: 3
Location: Tielt, Belgium
IMHO, i'm afraid that this won't work at runtime, since the actual scheme (table) in the resulting SQL will by aliased by hibernate.

e.g. schema_name param: 'myschema' will result in 'Product_0.myschema.part_group ... etc'

I guess that the dynamic alias should also be considered in this cases, meaning that, based on your 'schema_name' string, the dynamic alias related with that schema should be injected also. Resulting in something like 'MyShema_0.part_group ... etc'.


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.