Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting data where column is null in hibernate
    primarykey
    data
    text
    <p>I have written hql which work correctly in Hql editor but when I apply it in java code it give me Error.</p> <p>HQL Query which is working correctly</p> <pre><code>select auhority.id from Authority as auhority where auhority.action = 'USER_MASTER_FULL_ACCESS' and auhority.aclObject is NULL </code></pre> <p>Java Code for executing query</p> <pre><code>String hql = "from " + Authority.class.getCanonicalName() + " as model where model." + Authority.ACTION + " = ? and model." + Authority.ACL_OBJECT + " is null"; Query query = getSession().createQuery(hql); query.setParameter(0, action); List&lt;Authority&gt; list = query.list(); return list; </code></pre> <p>Here SecuredObject is ACL_OBJECT which is foreign key for Authority table which can be null. Otherwise other stuff ie add, update and delete is working correctly. I am using MsSqlserver 2005 for database.</p> <p>It give me error as follow</p> <pre><code>org.hibernate.TransientObjectException: object references an unsaved transientinstance - save the transient instance before flushing: com.xxxxx.xxxx.xxxx.SecuredObject at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:243) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:456) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:265) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:275) at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:295) at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:3403) at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:520) at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:230).... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload