Well... It seems to WANT to work... I decided to use findAll() instead just to see if I can get something out of the DB - which generated the following SQL - not sure why the other find didn't generate any SQL:
Code:
LOGGING: beginning transaction...
Hibernate: select ScapeUser.PARTY_ID as OBJECT_ID, ScapeUser.USERNAME as USERNAME43_, ScapeUser.PASSWORD as PASSWORD43_, ScapeUser.PASSWORD_EXPIRES as PASSWORD4_43_, ScapeUser.PASSWORD_RETENTION as PASSWORD5_43_, ScapeUser.PASSWORD_HINT as PASSWORD6_43_, ScapeUser.PASSWORD_ANSWER as PASSWORD7_43_, ScapeUser_1_.SSN as SSN42_, ScapeUser_1_.NAME_HUMAN_FIRST as NAME_HUM3_42_, ScapeUser_1_.NAME_HUMAN_MIDDLE as NAME_HUM4_42_, ScapeUser_1_.NAME_HUMAN_LAST as NAME_HUM5_42_, ScapeUser_1_.NAME_HUMAN_PREFIX as NAME_HUM6_42_, ScapeUser_1_.NAME_HUMAN_SUFFIX as NAME_HUM7_42_, ScapeUser_1_.DESCRIPTION as DESCRIPT8_42_, ScapeUser_2_.PARTY_TYPE_ID as PARTY_TY2_39_, ScapeUser_3_.ACCESS_PRIVILEGE as ACCESS_P2_0_, ScapeUser_3_.OBJECT_TYPE_ID as OBJECT_T3_0_ from Users ScapeUser inner join HUMAN ScapeUser_1_ on ScapeUser.PARTY_ID=ScapeUser_1_.PARTY_ID inner join PARTY ScapeUser_2_ on ScapeUser.PARTY_ID=ScapeUser_2_.PARTY_ID inner join OBJECT ScapeUser_3_ on ScapeUser.PARTY_ID=ScapeUser_3_.OBJECT_ID
Hibernate: select partytype0_.PARTY_TYPE_ID as OBJECT_ID3_, partytype0_.PARTY_TYPE_PARENT_ID as PARTY_TY2_14_3_, partytype0_.PARTY_TYPE as PARTY_TYPE14_3_, partytype0_.DESCRIPTION as DESCRIPT4_14_3_, partytype0__1_.ACCESS_PRIVILEGE as ACCESS_P2_0_3_, partytype0__1_.OBJECT_TYPE_ID as OBJECT_T3_0_3_, partytype1_.PARTY_TYPE_ID as OBJECT_ID0_, partytype1_.PARTY_TYPE_PARENT_ID as PARTY_TY2_14_0_, partytype1_.PARTY_TYPE as PARTY_TYPE14_0_, partytype1_.DESCRIPTION as DESCRIPT4_14_0_, partytype1__1_.ACCESS_PRIVILEGE as ACCESS_P2_0_0_, partytype1__1_.OBJECT_TYPE_ID as OBJECT_T3_0_0_, objecttype2_.OBJECT_TYPE_ID as OBJECT_ID1_, objecttype2_.OBJECT_TYPE as OBJECT_T2_5_1_, objecttype2_.DESCRIPTION as DESCRIPT3_5_1_, objecttype2__1_.ACCESS_PRIVILEGE as ACCESS_P2_0_1_, objecttype2__1_.OBJECT_TYPE_ID as OBJECT_T3_0_1_, objecttype3_.OBJECT_TYPE_ID as OBJECT_ID2_, objecttype3_.OBJECT_TYPE as OBJECT_T2_5_2_, objecttype3_.DESCRIPTION as DESCRIPT3_5_2_, objecttype3__1_.ACCESS_PRIVILEGE as ACCESS_P2_0_2_, objecttype3__1_.OBJECT_TYPE_ID as OBJECT_T3_0_2_ from TYPE_PARTY partytype0_ inner join OBJECT partytype0__1_ on partytype0_.PARTY_TYPE_ID=partytype0__1_.OBJECT_ID left outer join TYPE_PARTY partytype1_ on partytype0_.PARTY_TYPE_PARENT_ID=partytype1_.PARTY_TYPE_ID left outer join OBJECT partytype1__1_ on partytype1_.PARTY_TYPE_ID=partytype1__1_.OBJECT_ID left outer join TYPE_OBJECT objecttype2_ on partytype1__1_.OBJECT_TYPE_ID=objecttype2_.OBJECT_TYPE_ID left outer join OBJECT objecttype2__1_ on objecttype2_.OBJECT_TYPE_ID=objecttype2__1_.OBJECT_ID left outer join TYPE_OBJECT objecttype3_ on objecttype2__1_.OBJECT_TYPE_ID=objecttype3_.OBJECT_TYPE_ID left outer join OBJECT objecttype3__1_ on objecttype3_.OBJECT_TYPE_ID=objecttype3__1_.OBJECT_ID where partytype0_.PARTY_TYPE_ID=?
Hibernate: select objecttype0_.OBJECT_TYPE_ID as OBJECT_ID1_, objecttype0_.OBJECT_TYPE as OBJECT_T2_5_1_, objecttype0_.DESCRIPTION as DESCRIPT3_5_1_, objecttype0__1_.ACCESS_PRIVILEGE as ACCESS_P2_0_1_, objecttype0__1_.OBJECT_TYPE_ID as OBJECT_T3_0_1_, objecttype1_.OBJECT_TYPE_ID as OBJECT_ID0_, objecttype1_.OBJECT_TYPE as OBJECT_T2_5_0_, objecttype1_.DESCRIPTION as DESCRIPT3_5_0_, objecttype1__1_.ACCESS_PRIVILEGE as ACCESS_P2_0_0_, objecttype1__1_.OBJECT_TYPE_ID as OBJECT_T3_0_0_ from TYPE_OBJECT objecttype0_ inner join OBJECT objecttype0__1_ on objecttype0_.OBJECT_TYPE_ID=objecttype0__1_.OBJECT_ID left outer join TYPE_OBJECT objecttype1_ on objecttype0__1_.OBJECT_TYPE_ID=objecttype1_.OBJECT_TYPE_ID left outer join OBJECT objecttype1__1_ on objecttype1_.OBJECT_TYPE_ID=objecttype1__1_.OBJECT_ID where objecttype0_.OBJECT_TYPE_ID=?
Jan 19, 2004 5:55:04 PM org.apache.struts.action.RequestProcessor processException
WARNING: Unhandled Exception thrown: class net.sf.hibernate.PropertyAccessException
So then I got this error:
Code:
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of org.wgbh.scape.domain.ScapeUser.setContracts
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:216)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2137)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:239)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
at net.sf.hibernate.loader.Loader.list(Loader.java:940)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:833)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1475)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1446)
at org.wgbh.scape.domain.ScapeUserFinder.findAll(ScapeUserFinder.java:30)
at org.wgbh.scape.domain.UserDAOImpl.getUserFromLogin(UserDAOImpl.java:81)
at org.wgbh.scape.service.UserService.loginUser(UserService.java:84)
This would seem to be a problem with my mapping no? I don't have any data in the "Contracts," but it shouldn't be pertinent to a User object. Here's relevant pieces fo my mapping document. Note that the hierarchy goes like this:
UnidentifiedFoundationObject
|
--Party
|
--Human
|
--ScapeUser
|
--Organization
|
--Group
|
--Contract
So everything is a joined-subclass of UnidentifiedFoundationObject:
Code:
<hibernate-mapping package="org.wgbh.scape.domain" auto-import="false">
<class name="org.wgbh.scape.domain.UnidentifiedFoundationObject" polymorphism="explicit" table="OBJECT">
<meta attribute="class-description">
The UnidentifiedFoundationObject class is the base-class for all
objects within Scape. It is an abstract class.
@author Brian R. Wainwright
@version 1.0
</meta>
<meta attribute="implements">org.wgbh.scape.Associable</meta>
<id column="OBJECT_ID" name="objectID" type="string" unsaved-value="id_value">
<generator class="uuid.hex"/>
</id>
<property column="ACCESS_PRIVILEGE" insert="true" name="accessPrivilege"
type="string" update="true"/>
<many-to-one class="org.wgbh.scape.domain.ObjectType" column="OBJECT_TYPE_ID" name="objectType" />
<set name="associatedObjects" outer-join="auto" batch-size="30" lazy="false">
<key column="MASTER_OBJECT_ID"/>
<one-to-many class="org.wgbh.scape.domain.ObjectAssociation"/>
</set>
<set name="associatedProjects" lazy="false" outer-join="auto" batch-size="30">
<key column="ASSOCIATED_OBJECT_ID"/>
<one-to-many class="org.wgbh.scape.domain.ProjectAssociation"/>
</set>
<set name="associations" outer-join="auto" lazy="false" batch-size="30">
<key column="ASSOCIATED_OBJECT_ID"/>
<one-to-many class="org.wgbh.scape.domain.ObjectAssociation"/>
</set>
<set name="comments" inverse="true" lazy="false" outer-join="auto" batch-size="30">
<key column="OBJECT_ID"/>
<one-to-many class="org.wgbh.scape.domain.Comment"/>
</set>
<set name="attributes" inverse="true" outer-join="auto" lazy="false" batch-size="30">
<key column="OBJECT_ID"/>
<one-to-many class="org.wgbh.scape.domain.ObjectAttribute"/>
</set>
<set name="access" table="OBJECT_ACCESS_GROUP" lazy="false" outer-join="auto" batch-size="50">
<key column="OBJECT_ID"/>
<many-to-many class="org.wgbh.scape.domain.AccessGroup" column="ACCESS_GROUP_ID"/>
</set>
<joined-subclass name="org.wgbh.scape.domain.ObjectType" table="TYPE_OBJECT">
<meta attribute="class-description">
@author Brian R. Wainwright
@version 1.0
</meta>
<key column="OBJECT_TYPE_ID"/>
<property column="OBJECT_TYPE" name="objectTypeName" type="string">
<meta attribute="finder">findeByObjectTypeName</meta>
</property>
<property column="DESCRIPTION" name="description" type="text"/>
<set name="objects" batch-size="30" inverse="true" lazy="false" outer-join="auto">
<key column="OBJECT_TYPE_ID"/>
<one-to-many class="org.wgbh.scape.domain.UnidentifiedFoundationObject"/>
</set>
<set name="typeDefinitions" inverse="true" outer-join="auto" batch-size="30">
<key column="OBJECT_TYPE_ID"/>
<one-to-many class="org.wgbh.scape.domain.ObjectTypeDefinition"/>
</set>
</joined-subclass>
<joined-subclass name="org.wgbh.scape.domain.PartyType" table="TYPE_PARTY">
<meta attribute="class-description">
@author Brian R. Wainwright
@version 1.0
</meta>
<key column="PARTY_TYPE_ID"/>
<many-to-one name="parentType" class="org.wgbh.scape.domain.PartyType" column="PARTY_TYPE_PARENT_ID" outer-join="auto"/>
<property column="PARTY_TYPE" name="partyType" type="string">
<meta attribute="finder">findByType</meta>
</property>
<property column="DESCRIPTION" name="description" type="text"/>
<set batch-size="30" inverse="true" lazy="false" name="parties" outer-join="auto">
<key column="PARTY_TYPE_ID"/>
<one-to-many class="org.wgbh.scape.domain.Party"/>
</set>
<set name="childTypes" inverse="true" lazy="false" batch-size="30">
<key column="PARTY_TYPE_PARENT_ID"/>
<one-to-many class="org.wgbh.scape.domain.PartyType"/>
</set>
<set name="definitions" inverse="true" lazy="false" outer-join="auto" batch-size="30">
<key column="PARTY_TYPE_ID"/>
<one-to-many class="org.wgbh.scape.domain.PartyTypeDefinition"/>
</set>
</joined-subclass>
<joined-subclass name="org.wgbh.scape.domain.Party" table="PARTY">
<meta attribute="class-description">
@author Brian R. Wainwright
@version 1.0
</meta>
<key column="PARTY_ID"/>
<many-to-one class="org.wgbh.scape.domain.PartyType" column="PARTY_TYPE_ID" name="partyType">
<meta attribute="finder">findByPartyType</meta>
</many-to-one>
<set name="affiliatedParties" sort="natural" outer-join="auto" batch-size="30">
<key column="PARTY_ID"/>
<one-to-many class="org.wgbh.scape.domain.PartyAffiliation"/>
</set>
<set name="affiliations" outer-join="auto" sort="natural" batch-size="30">
<key column="AFFILIATED_PARTY_ID"/>
<one-to-many class="org.wgbh.scape.domain.PartyAffiliation"/>
</set>
<set name="addresses" inverse="true" outer-join="auto" sort="natural" table="ADDRESS">
<key column="PARTY_ID"/>
<one-to-many class="org.wgbh.scape.domain.Address"/>
</set>
<set name="emails" inverse="true" outer-join="auto" sort="natural" table="EMAIL">
<key column="PARTY_ID"/>
<one-to-many class="org.wgbh.scape.domain.Email"/>
</set>
<set name="phones" inverse="true" outer-join="auto" sort="natural" table="PHONE">
<key column="PARTY_ID"/>
<one-to-many class="org.wgbh.scape.domain.Phone"/>
</set>
<set name="contracts" table="CONTRACT_KPARTY" inverse="true" outer-join="auto" lazy="false" batch-size="30">
<key column="PARTY_ID"/>
<many-to-many class="org.wgbh.scape.domain.Contract" column="CONTRACT_ID"/>
</set>
<set name="partyComments" inverse="true" lazy="false" outer-join="auto" batch-size="30">
<key column="PARTY_ID"/>
<one-to-many class="org.wgbh.scape.domain.Comment"/>
</set>
<set name="partyAttributes" inverse="true" lazy="false" outer-join="auto" batch-size="30" sort="natural">
<key column="PARTY_ID"/>
<one-to-many class="org.wgbh.scape.domain.PartyAttribute"/>
</set>
<set name="projects" table="PROJECT_PARTY">
<key column="PARTY_ID"/>
<many-to-many class="org.wgbh.scape.domain.Project" column="PROJECT_ID" outer-join="auto"/>
</set>
<joined-subclass name="org.wgbh.scape.domain.Human" table="HUMAN">
<meta attribute="class-description">
@author Brian R. Wainwright
@version 1.0
</meta>
<key column="PARTY_ID"/>
<property column="SSN" insert="true" name="socialSecurityNumber"
type="string" update="true">
<meta attribute="finder">findBySSNumber</meta>
</property>
<property column="NAME_HUMAN_FIRST" insert="true" name="firstName"
type="string" update="true">
<meta attribute="finder">findByFirstName</meta>
</property>
<property column="NAME_HUMAN_MIDDLE" insert="true" name="middleName"
type="string" update="true">
<meta attribute="finder">findByMiddleName</meta>
</property>
<property column="NAME_HUMAN_LAST" insert="true" name="lastName" type="string" update="true">
<meta attribute="field-description">The last name of the person.</meta>
<meta attribute="finder">findByLastName</meta>
</property>
<property column="NAME_HUMAN_PREFIX" insert="true" name="namePrefix"
type="string" update="true"/>
<property column="NAME_HUMAN_SUFFIX" insert="true" name="nameSuffix"
type="string" update="true"/>
<property column="DESCRIPTION" insert="true" name="description"
type="string" update="true"/>
<joined-subclass name="org.wgbh.scape.domain.ScapeUser" table="Users">
<meta attribute="class-description">
A Users object represents a user of the application identified by a
username and a password.
@author Brian R. Wainwright
@version 1.0
</meta>
<key column="PARTY_ID"/>
<property column="USERNAME" insert="true" name="username"
type="string" update="true">
<meta attribute="finder">findByUsername</meta>
</property>
<property column="PASSWORD" insert="true" name="password"
type="string" update="true">
<meta attribute="finder">findByPassword</meta>
</property>
<property column="PASSWORD_EXPIRES" insert="true"
name="passwordExpires" type="calendar" update="true"/>
<property column="PASSWORD_RETENTION" insert="true"
name="passwordRetention" type="integer" update="true"/>
<property column="PASSWORD_HINT" insert="true"
name="passwordHint" type="string" update="true"/>
<property column="PASSWORD_ANSWER" insert="true"
name="passwordAnswer" type="string" update="true">
<meta attribute="finder">findByPwdAnswer</meta>
</property>
</joined-subclass>
</joined-subclass>
<joined-subclass name="org.wgbh.scape.domain.Organization" table="ORGANIZATION">
<meta attribute="class-description">
@author Brian R. Wainwright
@version 1.0
</meta>
<key column="PARTY_ID"/>
<property column="EIN" insert="true" name="employerIDNumber"
type="string" update="true">
<meta attribute="finder">findByEIN</meta>
</property>
<property column="ORGANIZATION_NAME" insert="true" name="name"
type="string" update="true">
<meta attribute="finder">findByName</meta>
</property>
<property column="DESCRIPTION" insert="true" name="description"
type="string" update="true"/>
<many-to-one class="org.wgbh.scape.domain.OrganizationType" column="ORGANIZATION_TYPE_ID"
insert="true" name="organizationType" outer-join="auto" update="true">
<meta attribute="finder">findByType</meta>
</many-to-one>
</joined-subclass>
<joined-subclass name="org.wgbh.scape.domain.Group" table="GROUPS">
<meta attribute="class-description">
@author Brian R. Wainwright
@version 1.0
</meta>
<key column="PARTY_ID"/>
<property column="GROUP_NAME" insert="true" name="name"
type="string" update="true">
<meta attribute="finder">findByName</meta>
</property>
<property column="DESCRIPTION" insert="true" name="description"
type="text" update="true"/>
</joined-subclass>
</joined-subclass>
</class>
Perhaps this isn't a great ORM model?