-->
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.  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Problem with HQL and MySQL
PostPosted: Mon Jan 19, 2004 1:06 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
Hey guys,

I had hbm2java generate domain classes and Finder classes based on my mapping. The HQL in the Finder doesn't seem to want to work. I'm using MySQL v4.0.17 and the latest version of org.gjt.mm.mysql.Driver. I'm also using Struts and the HibernatePlugIn slightly modified, but this seems to be working properly. In fact everything seems to be working properly, except the session.find(...) methods. What follows is the error:

Code:
javax.servlet.ServletException: Could not execute query
.
.
root cause
net.et.sf.hibernate.JDBCException: Could not execute query
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1478)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1450)
        at org.wgbh.scape.domain.UserFinder.findByUsername(UserFinder.java:15)
        at org.wgbh.scape.domain.UserDAOImpl.getUserFromLogin(UserDAOImpl.java:80)
        at org.wgbh.scape.service.UserService.loginUser(UserService.java:84)
        at org.wgbh.scape.action.ScapeLoginAction.loginUser(ScapeLoginAction.java:193)
        at org.wgbh.scape.action.ScapeLoginAction.login(ScapeLoginAction.java:59)
.
caused by: java.sql.SQLException: Syntax error or access violation,  message from server: "You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'from where (user.username='bwain' )' at line 1"
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1626)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:886)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:1844)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1458)
        at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:83)
        at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:794)
        at net.sf.hibernate.loader.Loader.doQuery(Loader.java:188)
        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)


My hibernate.cfg.xml

Code:

<hibernate-configuration>

    <session-factory name="scape:/hibernate/SessionFactory">

      <!-- <property name="connection.datasource">java:comp/env/jdbc/scapeDB</property>-->

        <property name="show_sql">false</property>
        <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
        <property name="connection.username">bwain</property>
        <property name="connection.password">n3pp13</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/scape?autoReconnect=true</property>
        <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
        <property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
        <property name="dbcp.minIdle">1</property>
        <property name="cache.use_query_cache">true</property>
        <property name="use_outer_join">true</property>

        <!-- Mapping files -->
        <mapping resource="object.hbm.xml"/>


    </session-factory>



Here's the complete Finder method:

Code:
    public static List findByUsername(Session session, java.lang.String username) throws SQLException, HibernateException {
        List finds = session.find("from User as user where user.username=?", username, Hibernate.STRING);
        return finds;
    }


and the mapping for the User class - which is a joined subclass.

Code:

<joined-subclass name="org.wgbh.scape.domain.User" table="Users">
               <meta attribute="class-description">
               A User 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>

[/code]

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 1:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Enable SQL logging and show the SQL hibernate generates.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 1:58 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
Eh... I don't have log4j configured yet (I know - blasphemy), but I did get a different error for some reason... I'll get the log4j config'd and post the SQL, but in the meantime, chew on this...THANKS!

Code:
net.sf.hibernate.QueryException: unexpected token: as [from User as user where user.username=?]
        at net.sf.hibernate.hql.FromParser.token(FromParser.java:94)
        at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
        at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
        at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
        at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
        at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1493)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1464)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1450)
        at org.wgbh.scape.domain.UserFinder.findByUsername(UserFinder.java:15)
        at org.wgbh.scape.domain.UserDAOImpl.getUserFromLogin(UserDAOImpl.java:80)
        at org.wgbh.scape.service.UserService.loginUser(UserService.java:84)
        at org.wgbh.scape.action.ScapeLoginAction.loginUser(ScapeLoginAction.java:193)


_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 2:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Are you sure hibernate found your mapping file? Do you really have it in your classpath root? Please enable logging and check that.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 2:16 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
Hi,

Yeah, I'm pretty sure - here's output from catalina.out:

Code:
INFO: Initializing, config='org.wgbh.scape.resources.ScapeResources', returnNull=true
Initializing Hibernate from /hibernate.cfg.xml...
Jan 19, 2004 12:43:15 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.1
Jan 19, 2004 12:43:15 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Jan 19, 2004 12:43:15 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jan 19, 2004 12:43:15 PM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from url: file:/usr/local/jakarta-tomcat-4.1.27/webapps/scape/WEB-INF/classes/hibernate.cfg.xml
Jan 19, 2004 12:43:16 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: object.hbm.xml
Jan 19, 2004 12:43:17 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: org.wgbh.scape.domain.UnidentifiedFoundationObject -> OBJECT
Jan 19, 2004 12:43:18 PM net.sf.hibernate.cfg.Binder bindCollection
INFO: Mapping collection: org.wgbh.scape.domain.UnidentifiedFoundationObject.access -> OBJECT_ACCESS_GROUP
Jan 19, 2004 12:43:18 PM net.sf.hibernate.cfg.Binder bindJoinedSubclass
INFO: Mapping joined-subclass: org.wgbh.scape.domain.ProjectAssociation -> PARTY_AFFILIATION
Jan 19, 2004 12:43:18 PM net.sf.hibernate.cfg.Binder bindJoinedSubclass
INFO: Mapping joined-subclass: org.wgbh.scape.domain.AccessGroup -> ACCESS_GROUP
...


And the app appears to be talking with the database through hibernate.

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 4:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
User is a restricted keyword or something

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 4:34 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
hmmm...good idea. I changed the class name, but still got an unexpected token error:

Code:
net.sf.hibernate.QueryException: unexpected token: as [from ScapeUser as scapeuser where scapeuser.username=?]
        at net.sf.hibernate.hql.FromParser.token(FromParser.java:94)
        at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
        at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
        at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
        at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
        at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1493)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1464)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1450)
        at org.wgbh.scape.domain.ScapeUserFinder.findByUsername(ScapeUserFinder.java:15)
        at org.wgbh.scape.domain.UserDAOImpl.getUserFromLogin(UserDAOImpl.java:80)


crap.

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 4:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ScapeUser is mapped and loaded ?
Try the full class name in query.
Which version of Hibernate do you use (try the latest) ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 7:06 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
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?

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 7:08 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
my little diagram didn't convery that Human is a joined-subclass of Party and as is Group and Organization while User is a joined-subclass of Human.

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 7:17 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
As said in the exception
set hibernate.cglib.use_reflection_optimizer=false for more info (in hibernate.properties or in -D )

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 6:13 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
alright - i'm back. I had some other issues with my mapping file - but i've worked those all out - I can now use the findAll() method in the generated finder class to successfully obtain a result set. My log files aren't showing any SQL that's being generated - as if the exception is being thrown before the SQL is generated. The only thing in the log file is:

WARNING: Unhandled Exception thrown: class net.sf.hibernate.QueryException

In any event here's more info about my install:

MySQL v 4.0.17 (using InnoDB tables)
Tomcat 4.1.27
Hibernate v2.1

I also tried using a Query object to no avail:

Code:
    public static List findByUsername(Session session, java.lang.String username) throws SQLException, HibernateException {
       
       Query q = session.createQuery("from User as user where user.username = :username");
   q.setString("username", username);
       return q.list();

}


thanks for the help![/code]

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 6:14 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
Using the Query object generated the same error - unexepcted token "as"...

THANKS!

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 6:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hm, probably I just overlook it, but do you really have a User class mapped? Shouldnt it be "from ScapeUser"?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 8:02 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
I had changed the class name from User to ScapeUser at the thought that perhaps User was a reserved word of some kind. It doesn't seem to be so I changed back to User. So the mapping file and the error message etc... are as they are in the first post. Thanks for the attention to detail.

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 21 posts ]  Go to page 1, 2  Next

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.