-->
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.  [ 1 post ] 
Author Message
 Post subject: Filters H3 beta
PostPosted: Wed Dec 29, 2004 11:06 am 
Newbie

Joined: Tue Jul 06, 2004 11:25 am
Posts: 2
Hi, all
i can't filter by parent property. h3 don't include filter restriction in sql where clause.


Hibernate version: 3 beta

Mapping documents:

<class name="test.Abc" table="ENT_ABC" discriminator-value="null">

<id name="id" type="java.lang.String" column="M_ID" unsaved-value="null" >
<generator class="uuid"/>
</id>

<discriminator formula="M_CLASS" type="string" not-null="true" insert="false"/>

<property name="revisionStatus" type="java.lang.Integer" column="M_SYS_STATUS" not-null="true" length="22"/>

<property name="prop" type="java.lang.String" column="M_PROP" not-null="true"/>
<property name="clazz" type="java.lang.Integer" column="M_CLASS" not-null="true"/>

<subclass name="test.SubClass2" discriminator-value="null">

<property name="sub2Prop" type="java.lang.String" column="M_SUB2_PROP"/>

<subclass name="test.SubClass21" discriminator-value="3">
<property name="sub21Prop" type="java.lang.String" column="M_SUB21_PROP"/>
</subclass>

<subclass name="test.SubClass22" discriminator-value="4">
<property name="sub22Prop" type="java.lang.String" column="M_SUB22_PROP"/>

</subclass>
</subclass>

<filter name="archiveFilter" condition="M_SYS_STATUS = :isArchive" />
<filter name="prop2" condition="M_SUB22_PROP = :prop" />

</class>
<filter-def name="archiveFilter">
<filter-param name="isArchive" type="integer"/>
</filter-def>

<filter-def name="prop2">
<filter-param name="prop" type="string"/>
</filter-def>
</code>

Code between sessionFactory.openSession() and session.close():

Session session = HibernateSession.getCurrentSession();
Transaction t = session.beginTransaction();

String query = "from SubClass22";

session.enableFilter("archiveFilter").setParameter("isArchive", new Integer(1));
session.createQuery(query).list();

session.enableFilter("prop2").setParameter("prop", "xxx");
session.createQuery(query).list();

t.commit();
session.close();

Full stack trace of any exception that occurs:

Name and version of the database you are using:
HSQLDB 1.7

The generated SQL (show_sql=true):
DEBUG SQL:290 - select subclass22x0_.M_ID as M_ID, subclass22x0_.M_SYS_COMMENT as M_SYS_CO2_0_, subclass22x0_.M_SYS_STATUS as M_SYS_ST3_0_, subclass22x0_.M_PROP as M_PROP0_, subclass22x0_.M_CLASS as M_CLASS0_, subclass22x0_.M_TYPE as M_TYPE0_, subclass22x0_.M_SUB2_PROP as M_SUB2_10_0_, subclass22x0_.M_SUB22_PROP as M_SUB2212_0_ from ENT_ABC subclass22x0_ where subclass22x0_.M_CLASS='4'

DEBUG SQL:290 - select subclass22x0_.M_ID as M_ID, subclass22x0_.M_SYS_COMMENT as M_SYS_CO2_0_, subclass22x0_.M_SYS_STATUS as M_SYS_ST3_0_, subclass22x0_.M_PROP as M_PROP0_, subclass22x0_.M_CLASS as M_CLASS0_, subclass22x0_.M_TYPE as M_TYPE0_, subclass22x0_.M_SUB2_PROP as M_SUB2_10_0_, subclass22x0_.M_SUB22_PROP as M_SUB2212_0_ from ENT_ABC subclass22x0_ where subclass22x0_.M_CLASS='4'

i would like see such generated sql:
select * from ent_abc where m_class = 4 and m_sys_status = 1
and if i filter by own property (sub22Prop)
h3 generate
select * from ent_abc where m_class = 4 and m_sub22_prop = 'blablabla'

2.same behavior if i use joined-subclass
3. could anyone point me where hibernate developers explaine why filtering not allowed to many-to-one, only one-to-many.
4. how can i create filetr and that filetr will filtering by list of values and generate such sql:
... where .. and (t.prop in ($first_value$, $second_value$, ... $last_value$))
if on development time i don't know count of params ?

thanks, Alexandr


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.