-->
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: Problem querying associated table set of string elements?
PostPosted: Thu Nov 17, 2005 3:17 pm 
Beginner
Beginner

Joined: Wed Oct 19, 2005 3:30 pm
Posts: 25
I can run querys of the main table of the database just fine however Im running into some trouble trying to query associated tables, in this case specifically the associated strings element table called scholarshipXmajor.
Hibernate version:
hibernate-3.0.5
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!--
Document : Scholarship.hbm.xml
Created on : March 1, 2005, 1:42 PM
Author : dsobiera
Description:
Purpose of the document follows.
-->

<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="edu.asu.SFAO.DAOs.Scholarship" table="scholarship">
<meta attribute="class-description">
A representation of an ASU scholarship
</meta>

<id name="id" column="scholarshipID" unsaved-value="0" >
<meta attribute="scope-set">protected</meta>
<generator class="native"> </generator>
</id>

<property name="name" type="string" not-null="true" column="name"> </property>
<property name="amountType" type="int" not-null="true" column="amount_type"> </property>
<property name="amount" type="int" not-null="true" column="amount"> </property>
<property name="activationDate" type="string" not-null="true" column="activation_date"> </property>
<property name="deadlineDate" type="string" not-null="true" column="deadline_date"> </property>
<property name="openDeadline" type="int" not-null="true" column="open_deadline"> </property>
<property name="applicationUrl" type="string" not-null="true" column="application_url"> </property>
<property name="needBased" type="int" not-null="true" column="need_based"> </property>
<property name="globalList" type="int" not-null="true" column="global_list"> </property>
<property name="minimumGpa" type="int" not-null="true" column="minimum_gpa"> </property>
<property name="minimumHours" type="int" not-null="true" column="minimum_hours"> </property>
<property name="azResident" type="int" not-null="true" column="az_resident"> </property>
<property name="condition" type="string" not-null="true" column="condition"> </property>
<property name="eligibility" type="string" not-null="true" column="eligibility"> </property>
<property name="description" type="string" not-null="true" column="description"> </property>
<property name="comment" type="string" not-null="true" column="comment"> </property>
<property name="contactName" type="string" not-null="true" column="contact_name"> </property>
<property name="contactOrganization" type="string" not-null="true" column="contact_organization"> </property>
<property name="contactPhone" type="string" not-null="true" column="contact_phone"> </property>

<set name="campuses" table="scholarshipXcampus" inverse="false" cascade="all">
<meta attribute="field-description">
A scholarship can have many campuses associated with it
</meta>
<key column="scholarshipID" />
<many-to-many class="edu.asu.SFAO.DAOs.Campus" column="campusID" />
</set>

<set name="classstandings" table="scholarshipXclassstanding" inverse="false" cascade="all">
<meta attribute="field-description">
A scholarship can have many classstandings associated with it
</meta>
<key column="scholarshipID" />
<many-to-many class="edu.asu.SFAO.DAOs.ClassStanding" column="classstandingID" />
</set>

<set name="donorPrefs" table="scholarshipXdonorpref" inverse="false" cascade="all">
<meta attribute="field-description">
A scholarship can have many donor preferences associated with it
</meta>
<key column="scholarshipID" />
<many-to-many class="edu.asu.SFAO.DAOs.DonorPref" column="donorprefID" />
</set>

<set name="majors" table="scholarshipXmajor" inverse="false" cascade="all">
<meta attribute="field-description">
A scholarship can have many majors associated with it
</meta>
<key column="scholarshipID"/>
<element column="majorCode" type="string"/>
</set>

</class>

<query name="edu.asu.SFAO.getAllScholarships" >
<![CDATA[
from edu.asu.SFAO.DAOs.Scholarship as scholarship
order by scholarship.deadlineDate ASC
]]>
</query>

<query name="edu.asu.SFAO.getGlobalScholarships">
<![CDATA[
from edu.asu.SFAO.DAOs.Scholarship as scholarship
where scholarship.globalList=1
order by scholarship.deadlineDate ASC
]]>
</query>

<query name="edu.asu.SFAO.getActiveScholarships">
<![CDATA[
from edu.asu.SFAO.DAOs.Scholarship as scholarship
where scholarship.activationDate <= :today and scholarship.deadlineDate >= :today
order by scholarship.deadlineDate ASC
]]>
</query>

<query name="edu.asu.SFAO.getSpecificScholarship">
<![CDATA[
from edu.asu.SFAO.DAOs.Scholarship as scholarship
where scholarship.id = :id
]]>
</query>

<query name="edu.asu.SFAO.getApplicableScholarships">
<![CDATA[
from edu.asu.SFAO.DAOs.Scholarship as scholarship
where scholarship.majors = :majors
]]>
</query>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
hibScholarshipSearchSession = sessionFactory1.openSession();
scholarships = hibScholarshipSearchSession.getNamedQuery("edu.asu.SFAO.getApplicableScholarships")
.setString("majors","-1")
.list();

Name and version of the database you are using:
ms sql (not sure verison)
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:

13:14:11,931 DEBUG SQL:324 - select scholarshi0_.scholarshipID as scholars1_, scholarshi0_.name as name3_, scholarshi0_.amount_type as amo
unt3_3_, scholarshi0_.amount as amount3_, scholarshi0_.activation_date as activation5_3_, scholarshi0_.deadline_date as deadline6_3_, scho
larshi0_.open_deadline as open7_3_, scholarshi0_.application_url as applicat8_3_, scholarshi0_.need_based as need9_3_, scholarshi0_.global
_list as global10_3_, scholarshi0_.minimum_gpa as minimum11_3_, scholarshi0_.minimum_hours as minimum12_3_, scholarshi0_.az_resident as az
13_3_, scholarshi0_.condition as condition3_, scholarshi0_.eligibility as eligibi15_3_, scholarshi0_.description as descrip16_3_, scholars
hi0_.comment as comment3_, scholarshi0_.contact_name as contact18_3_, scholarshi0_.contact_organization as contact19_3_, scholarshi0_.cont
act_phone as contact20_3_ from scholarship scholarshi0_, scholarshipXmajor majors1_ where scholarshi0_.scholarshipID=majors1_.scholarshipI
D and .=?
13:14:12,084 WARN JDBCExceptionReporter:71 - SQL Error: 170, SQLState: 37000
13:14:12,085 ERROR JDBCExceptionReporter:72 - Line 1: Incorrect syntax near '='.


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.