-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to do SQLQuery for inheritance
PostPosted: Fri Dec 07, 2007 6:09 pm 
Newbie

Joined: Fri Dec 07, 2007 5:41 pm
Posts: 1
I am using Hibernate 3.2.5, MS SQL Server 2000, and JDK 1.5.

I need to use SQLQuery for full-text index search in two entities with inheritance relationship. I am using MS SQL Server's full text index.

Here is my simplified mapping file:

<class name="Parent" table="TEST_PARENT">

<id name="id" type="long" column="ID">
<meta attribute="scope-set">public</meta>
<generator class="native"/>
</id>

<property name="name" type="string">
<column name="NAME" length="40"/>
</property>

<joined-subclass name="Child" table="TEST_CHILD" lazy="false">

<key column="CHILD_ID"/>

<property name="childName" type="string">
<column name="CHILD_NAME" length="40"/>
</property>

</joined-subclass>

</class>


I am trying to do a search such as follows:

String qry = "question 1"; // use contains clause
SQLQuery q = s.createSQLQuery(qry).addEntity(question 2);
List list = q.list();

I have difficulty writing the correct query and building SQLQuery (see question 1 and 2). I tried many possibilities and always got errors.

I searched the forum and did not see any examples. The online Hibernate Reference Documentation says very lightly about this inheritance situation.

Does anyone have examples about this situation? I got stuck. I really appreciate any help.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 10, 2007 10:12 am 
Newbie

Joined: Mon Oct 29, 2007 2:33 pm
Posts: 16
Location: Cambridge, MA
I don't know how to do exactly what you are asking, because it involves both non-standard SQL and inheritance, but if you use HQL instead, where you are in the inheritance world, you can use "extra" SQL functions in the WHERE clause of the query and Hibernate will pass them through to the database, something like

from <top-level class> where contains(name, '"foo*" near bar')

to find names containing foo* and bar.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 10, 2007 10:13 am 
Newbie

Joined: Mon Oct 29, 2007 2:33 pm
Posts: 16
Location: Cambridge, MA
Ignore this accidental post


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