Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.6.ga
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="be.rmi.shark.hibernate.persistence">
<class name="ProcessPersistence" table="Shark_Process">
<id column="objectId" type="long">
<generator class="sequence">
<param name="sequence">shark_sequence</param>
</generator>
</id>
<property name="deleted" />
<many-to-one name="activityRequester" />
<property name="activityRequestersProcessId"/>
<property name="createdTime" not-null="true" column="created"/>
<property name="description" not-null="true" type="text"/>
<property name="externalRequesterClassName"/>
<property name="id" not-null="true"/>
<property name="lastStateTime" not-null="true"/>
<property name="limitTime" not-null="true"/>
<property name="name"/>
<property name="priority"/>
<many-to-one name="manager" not-null="true"/>
<many-to-one name="resourceRequester" not-null="true"/>
<property name="startedTime" column="started"/>
<property name="state" not-null="true"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
public ProcessPersistence restoreProcess(String procId,
SharkTransaction ti) throws PersistenceException {
return (ProcessPersistence) load(ti,"from ProcessPersistence x where x.id = ?",procId);
}
public SharkObjectPersistence load(SharkTransaction ti, String query, Object... parameters) throws HibernatePersistenceException{
try{
if (log.isDebugEnabled())
log.debug("Loading "+query);
Session s = (Session)((HibernateTransaction)ti).getHibernateSession();
Query q = s.createQuery(query);
int i=0;
for (Object parameter : parameters)
q.setParameter(i++, parameter);
return (SharkObjectPersistence)q.uniqueResult();
} catch (HibernateException e){
throw new HibernatePersistenceException("could not load "+query,e);
}
}
Full stack trace of any exception that occurs:Code:
java.lang.NullPointerException
at org.hibernate.util.StringHelper.root(StringHelper.java:150)
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1378)
at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31)
at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1354)
at org.hibernate.hql.ast.tree.FromElement.getIdentityColumn(FromElement.java:296)
at org.hibernate.hql.ast.tree.IdentNode.resolveAsAlias(IdentNode.java:131)
at org.hibernate.hql.ast.tree.IdentNode.resolve(IdentNode.java:77)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4386)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExprLhs(HqlSqlBaseWalker.java:4830)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4311)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1212)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at be.rmi.shark.hibernate.persistence.PersistenceManager.load(PersistenceManager.java:577)
at be.rmi.shark.hibernate.persistence.PersistenceManager.restoreProcess(PersistenceManager.java:600)
at be.rmi.shark.hibernate.persistence.PersistenceManager.persist(PersistenceManager.java:483)
at <hibernate unrelated tomcat call stuff and buisness code>
Name and version of the database you are using:The generated SQL (show_sql=true):none
Hello,
i try to use the following hql query:
Code:
from ProcessPersistence x where x.id = ?
the id is not the hibernate identifier of entity (hibernate is supposed to use objectId identifier). However, since older version of hibernate (3.0.5) does not support bean property other thant identifier named id, i had to upgrade to a > 3.2.2 hibernate version. Now am getting that nullpointerexception :/
I can't change the name of property (id) to something not clashing with hql because it's a mandatory property in an interface am implementing. Is it a known problem with hibernate, are there any workaround? Do i have to push an issue in jira for this?