I'm using Hibernate 3.0.5 and am trying to run the following HQL query
Code:
select user.uid,user.password,user.authorities from UserBackingData as user where user.username = ?
This causes Hibernate to throw a NPE. I've tried with different combinations of joins but nothing seems to help except for taking the user.authorities select element out. I'm not sure what's going on, but I'm guessing it's my mapping. Any ideas?
Thanks,
Rich
PS. the mapping for UserDetails is below as is the full stack trace for the exception.
Code:
<hibernate-mapping>
<class name="com.contentconnections.mpl.publisher.auth.UserBackingData" table="mpl_users">
<id name="uid" column="uid" >
<generator class="uuid" />
</id>
<natural-id mutable="true">
<property name="username" />
</natural-id>
<property name="password" />
<set name="authorities" table="mpl_authorities" lazy="true">
<key column="uid" />
<composite-element class="com.contentconnections.mpl.publisher.auth.MutableGrantedAuthority">
<property name="authority" />
</composite-element>
</set>
<one-to-one name="profile" lazy="false" />
</class>
</hibernate-mapping>
Code:
java.lang.NullPointerException
at org.hibernate.hql.ast.FromElementType.renderIdentifierSelect(FromElementType.java:139)
at org.hibernate.hql.ast.FromElement.renderIdentifierSelect(FromElement.java:162)
at org.hibernate.hql.ast.SelectClause.renderNonScalarIdentifiers(SelectClause.java:372)
at org.hibernate.hql.ast.SelectClause.renderNonScalarSelects(SelectClause.java:350)
at org.hibernate.hql.ast.SelectClause.initializeExplicitSelectClause(SelectClause.java:192)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:440)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:351)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.afterQuery(HqlSqlBaseWalker.java:126)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:471)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:751)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:312)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:742)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:738)
at com.contentconnections.mpl.publisher.auth.AuthenticationManagementDaoHibernateImpl.loadUserByUsername(AuthenticationManagementDaoHibernateImpl.java:47)
at com.contentconnections.mpl.publisher.auth.test.AuthenticationManagementDaoHibernateImplTest.testLoadUserByUsername(AuthenticationManagementDaoHibernateImplTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[/code]