-->
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.  [ 4 posts ] 
Author Message
 Post subject: hbm and hibernate 'select' query
PostPosted: Tue Jul 19, 2005 6:02 pm 
Newbie

Joined: Fri May 06, 2005 5:11 pm
Posts: 14
Location: San Francisco
Hello,

I'm a hibernate newbie. I generate the hbm.xml files with middle gen. I have two table profile (profile_id_no as primary key) and education (has education_id_no as primary key and profile_id_no as foreign key) .

profile --> education is one to many mapping.

Now, I need to run a query to find education by profile_id_no. Since the education.hbm.xml file was generated by middlegen, profile_id_no is not shown in the property tag, I can't do 'select from education ... where profileIdNo = ..."

Could anyone show me another way of getting education back by profile_id_no? Thank you very much for your help.

Below is my mapping file.

<hibernate-mapping>
<class name="data.hibernate.web.Education" table="EDUCATION">
<meta attribute="class-description" inherit="false">
@hibernate.class
table="EDUCATION"
</meta>

<id
name="educationIdNo"
type="java.lang.Integer"
column="EDUCATION_ID_NO"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="java.lang.Integer"
column="EDUCATION_ID_NO"

</meta>
<generator class="assigned" />
</id>

<property
name="createDt"
type="java.sql.Timestamp"
column="CREATE_DT"
not-null="true"
length="26"
>
<meta attribute="field-description">
@hibernate.property
column="CREATE_DT"
length="26"
not-null="true"
</meta>
</property>
<property
name="schoolName"
type="java.lang.String"
column="SCHOOL_NAME"
length="80"
>
<meta attribute="field-description">
@hibernate.property
column="SCHOOL_NAME"
length="80"
</meta>
</property>
<property
name="degree"
type="java.lang.String"
column="DEGREE"
length="80"
>
<meta attribute="field-description">
@hibernate.property
column="DEGREE"
length="80"
</meta>
</property>
<property
name="graduatedDt"
type="java.sql.Timestamp"
column="GRADUATED_DT"
length="26"
>
<meta attribute="field-description">
@hibernate.property
column="GRADUATED_DT"
length="26"
</meta>
</property>
<property
name="major"
type="java.lang.String"
column="MAJOR"
length="40"
>
<meta attribute="field-description">
@hibernate.property
column="MAJOR"
length="40"
</meta>
</property>

<!-- Associations -->

<!-- bi-directional many-to-one association to ProfileEntity -->
<many-to-one
name="profile"
class="data.hibernate.web.Profile"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="PROFILE_ID_NO"
@hibernate.column name="PROFILE_ID_NO"
</meta>
<column name="PROFILE_ID_NO" />
<column name="PROFILE_ID_NO" />
</many-to-one>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 8:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
from education as ed where ed.profile.id = ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 9:18 pm 
Newbie

Joined: Fri May 06, 2005 5:11 pm
Posts: 14
Location: San Francisco
Yeah .. I already found the answer. I'm trying to have a crash course of hibernate. Looks like it's not working... :)

from Class.Education as education where education.profile.profileIdNo = <value>

Thanks,
Sahra


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 9:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Its working fine. ORM is a difficult subject to master. Your well on your way.


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