Hi,
I have table PRESENTER which has a many-to-one relationship with table FACULTY. There can be n number of faculty for an event in EVENT. PRESENTER acts as a map between the two.
Everything works fine but when I get to display the faculty information like first name, etc. I get an error. I can, however, display the id of the faculty member.
I'm using Hibernate with Struts. I'm not exactly sure but I think my problem lies in my mapping documents. This question straddles the line between Struts and Hibernate but I'm pretty sure it's on the Hibernate side.
Any help?
Thanks,
Jon
Hibernate version:
3.2
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 7, 2007 6:32:01 AM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.bem.ebi.event.model.Event" table="EVENTS" catalog="ebi">
<comment></comment>
<id name="id" type="int">
<column name="ID" />
<generator class="identity" />
</id>
<set name="presenters" table="PRESENTERS" lazy="true">
<key column="EVENT_ID"/>
<one-to-many class="com.bem.ebi.presenter.model.Presenter"/>
</set>
<property name="projectId" type="int">
<column name="PROJECT_ID" not-null="true">
<comment></comment>
</column>
</property>
<property name="eventCode" type="string">
<column name="EVENT_CODE" length="10">
<comment></comment>
</column>
</property>
<property name="eventName" type="string">
<column name="EVENT_NAME" length="211">
<comment></comment>
</column>
</property>
<property name="eventDate" type="date">
<column name="EVENT_DATE" length="10">
<comment></comment>
</column>
</property>
<property name="startTime" type="string">
<column name="START_TIME" length="20">
<comment></comment>
</column>
</property>
<property name="endTime" type="string">
<column name="END_TIME" length="20">
<comment></comment>
</column>
</property>
<property name="location" type="string">
<column name="LOCATION" length="50">
<comment></comment>
</column>
</property>
<property name="address" type="string">
<column name="ADDRESS" length="50">
<comment></comment>
</column>
</property>
<property name="addressAdditional" type="string">
<column name="ADDRESS_ADDITIONAL" length="50">
<comment></comment>
</column>
</property>
<property name="city" type="string">
<column name="CITY" length="50">
<comment></comment>
</column>
</property>
<property name="state" type="string">
<column name="STATE" length="50">
<comment></comment>
</column>
</property>
<property name="zip" type="string">
<column name="ZIP" length="5">
<comment></comment>
</column>
</property>
<property name="phone" type="string">
<column name="PHONE" length="12">
<comment></comment>
</column>
</property>
<property name="fax" type="string">
<column name="FAX" length="12">
<comment></comment>
</column>
</property>
<property name="email" type="string">
<column name="EMAIL" length="50">
<comment></comment>
</column>
</property>
<property name="url" type="string">
<column name="URL" length="211">
<comment></comment>
</column>
</property>
<property name="contactFirstName" type="string">
<column name="CONTACT_FIRST_NAME" length="50">
<comment></comment>
</column>
</property>
<property name="contactLastName" type="string">
<column name="CONTACT_LAST_NAME" length="50">
<comment></comment>
</column>
</property>
<property name="maxCapacity" type="int">
<column name="MAX_CAPACITY" not-null="true">
<comment></comment>
</column>
</property>
<property name="dateAdded" type="date">
<column name="DATE_ADDED" length="10" not-null="true">
<comment></comment>
</column>
</property>
<property name="dateModified" type="date">
<column name="DATE_MODIFIED" length="10" not-null="true">
<comment></comment>
</column>
</property>
</class>
<query name="com.bem.ebi.event.model.getEventsForProject">
<![CDATA[
from com.bem.ebi.event.model.Event as event
where event.projectId = :id
]]>
</query>
<query name="com.bem.ebi.event.model.getEvent">
<![CDATA[
from com.bem.ebi.event.model.Event as event
where event.id = :id
]]>
</query>
<query name="com.bem.ebi.event.model.deleteEvent">
<![CDATA[
from com.bem.ebi.event.model.Event as event
where event.id = :id
]]>
</query>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 22, 2007 6:49:42 AM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.bem.ebi.presenter.model.Presenter" table="PRESENTERS" catalog="ebi">
<comment></comment>
<id name="id" type="int">
<column name="ID" />
<generator class="identity" />
</id>
<many-to-one name="faculty" class="com.bem.ebi.model.Faculty" column="id"/>
<property name="eventId" type="int">
<column name="EVENT_ID" not-null="true">
<comment></comment>
</column>
</property>
<property name="presenterId" type="int">
<column name="PRESENTER_ID" not-null="true">
<comment></comment>
</column>
</property>
<property name="dateAdded" type="date">
<column name="DATE_ADDED" length="10" not-null="true">
<comment></comment>
</column>
</property>
<property name="dateModified" type="date">
<column name="DATE_MODIFIED" length="10" not-null="true">
<comment></comment>
</column>
</property>
<property name="modifiedBy" type="int">
<column name="MODIFIED_BY" not-null="true">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jan 14, 2007 6:54:10 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.bem.ebi.model.Faculty" table="FACULTY" catalog="ebi" lazy="true">
<comment></comment>
<id name="id" type="int">
<column name="ID" />
<generator class="assigned" />
</id>
<property name="firstName" type="string">
<column name="FIRST_NAME" length="50" not-null="true">
<comment></comment>
</column>
</property>
<property name="middleName" type="string">
<column name="MIDDLE_NAME" length="50">
<comment></comment>
</column>
</property>
<property name="lastName" type="string">
<column name="LAST_NAME" length="50" not-null="true">
<comment></comment>
</column>
</property>
<property name="suffix" type="string">
<column name="SUFFIX" length="10">
<comment></comment>
</column>
</property>
<property name="specialty" type="string">
<column name="SPECIALTY" length="50">
<comment></comment>
</column>
</property>
<property name="dateAdded" type="date">
<column name="DATE_ADDED" length="10" not-null="true">
<comment></comment>
</column>
</property>
<property name="dateModified" type="date">
<column name="DATE_MODIFIED" length="10" not-null="true">
<comment></comment>
</column>
</property>
<property name="modifiedBy" type="int">
<column name="MODIFIED_BY" not-null="true">
<comment></comment>
</column>
</property>
</class>
<query name="com.bem.ebi.model.getAllFaculty">
<![CDATA[
from com.bem.ebi.model.Faculty as faculty
order by faculty.id asc
]]>
</query>
<query name="com.bem.ebi.model.getOneFacultyMember">
<![CDATA[
from com.bem.ebi.model.Faculty as faculty
where faculty.id = :id
]]>
</query>
<query name="com.bem.ebi.model.deleteFacultyMember">
<![CDATA[
from com.bem.ebi.model.Faculty as faculty
where faculty.id = :id
]]>
</query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): Using Open Session in View
Full stack trace of any exception that occurs:
Name and version of the database you are using:
MySQL 4.1
The generated SQL (show_sql=true):
|