HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

Chintan Patel

I have 2 tables with One-To-Many relationship as per following:

Table Relationship

My entity classes and hbm configurations are as per following:

AuditDetail.java

public class AuditDetail implements Serializable {

    private static final long serialVersionUID = 1L;
    private String auditId;
    private Timestamp startTime;
    private Timestamp endTime;
    Set auditParameterDataSet;

    public Set getAuditParameterDataSet() {
        return auditParameterDataSet;
    }
    public void setAuditParameterDataSet(Set auditParameterDataSet) {
        this.auditParameterDataSet = auditParameterDataSet;
    }
    public String getAuditId() {
        return auditId;
    }
    public void setAuditId(String auditId) {
        this.auditId = auditId;
    }
    public void setStartTime(Timestamp startTime) {
        this.startTime = startTime;
    }
    public Timestamp getEndTime() {
        return  endTime;        
    }
    public void setEndTime(Timestamp endTime) {
        this.endTime = endTime;
    }   
}

AuditDetail.hbm.xml

<hibernate-mapping>

    <class name="com.test.AuditDetail" table="AUDITDETAIL" >          

        <id name="auditId" column="AUDITID" type="string" />

         <property name="startTime" type="java.sql.Timestamp">
              <column name="STARTTIME" sql-type="VARCHAR2(50)" />
         </property>

         <property name="endTime" type="java.sql.Timestamp">
              <column name="ENDTIME" sql-type="VARCHAR2(50)" />
         </property>

        <set name="auditParameterDataSet" cascade="all,delete-orphan" lazy="true" inverse="true">
            <key>
                <column name="AUDITID"/>
            </key>
            <one-to-many class="com.test.AuditParameter" />
        </set>

    </class>

</hibernate-mapping>

AuditParameter.java

public class AuditParameter {

    private String auditId ;
    private String parameterId;
    private String fieldName ;
    private AuditDetail auditDetail;

    public String getAuditId() {
        return auditId;
    }
    public void setAuditId(String auditId) {
        this.auditId = auditId;
    }
    public String getParameterId() {
        return parameterId;
    }
    public void setParameterId(String parameterId) {
        this.parameterId = parameterId;
    }
    public String getFieldName() {
        return fieldName;
    }
    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }
    public AuditDetail auditDetail() {
        return auditDetail;
    }
    public void setAuditDetail(AuditDetail auditDetail) {
        this.auditDetail = auditDetail;
    }

}

AuditParameter.hbm.xml

<hibernate-mapping>

    <class name="com.test.AuditParameter" table="AUDITPARAMETER" >          

         <id name="parameterId" type="string">
              <column name="PARAMETERID" sql-type="VARCHAR2(50)"  />
        </id>

        <many-to-one name="auditDetail" class="com.test.AuditDetail" column="AUDITID" insert="false" update="false" lazy="false">
        </many-to-one>

        <property name="auditId" type="string">
              <column name="AUDITID" sql-type="VARCHAR2(50)" not-null="false" />
        </property>

        <property name="fieldName" type="string">
              <column name="FIELDNAME" sql-type="VARCHAR2(50)" />
        </property>


    </class>
</hibernate-mapping>

My hql query is a per following:

select a.auditId, a.startTime, a.endTime, a.auditParameterDataSet from AuditDetail a;

But when I execute this query, it gives me following error:

ORA-00936: missing expression

Following is my console output of query fired.

select au0_.AUDITID as col_0_0_, au0_.STARTTIME as col_1_0_, au0_.ENDTIME as col_2_0_, . as col_3_0_ 
from AUDITDETAIL au0_ inner join AUDITPARAMETER auditparam4_ on au0_.AUDITID=auditparam4_.AUDITID

As per this output we can see that hibernate is not generating column name for a.auditParameterDataSet. Why this is happening? Where I am doing wrong?

karim mohsen

You have to use join :-

HQL:-

select a.auditId, a.startTime, a.endTime, auditParameterDataSet from AuditDetail join a.auditParameterDataSet auditParameterDataSet;

Criteria:-

Criteria criteria = session.createCriteria(AuditDetail.class);
criteria.setFetchMode("auditParameterDataSet", FetchMode.EAGER);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

From Dev

ORA 00936 Missing Expression

From Dev

ora:00936 Missing Expression error

From Dev

ORA-00936: missing expression distinct on oracle

From Dev

ORA-00936: missing expression - what is the cause?

From Dev

ORA-00936: missing expression oracle

From Dev

ORA-00936: missing expression in order by case

From Dev

SQL Error -- ORA-00936: missing expression

From Dev

ORA-00936: Missing Expression Teradata

From Dev

ORA-00936: missing expression error when inserting values

From Dev

ORA-00936: missing expression, although there seems to be no missing expression (SQL)

From Dev

Entity Framework ExecuteStoreCommand gives {"ORA-00936: missing expression"}

From Dev

ORA-00936: missing expression bad SQL grammar

From Dev

ORA-00936: missing expression while executing in C#.

From Dev

ORA-00936: missing expression, although there seems to be no missing expression (SQL)

From Dev

ORA-00936: missing expression ORACLE please help me

From Dev

Oracle data access error: ORA-00936: missing expression

From Dev

ORA-00936: missing expression while using stringbuilder

From Dev

getting java.sql.SQLSyntaxErrorException: ORA-00936: missing expression error

From Dev

Sql throws 'DBError: ORA-00936: missing expression' when empty expression_list is passed

From Dev

retrieve value from One-To-Many relationship Hibernate Without HQL

From Dev

hql select query on one to many relationship in spring jpa

From Dev

HQL query for Many to Many Explict relationship

From Dev

ORA-06550: line 12, column 9: PL/SQL: ORA-00936: missing expression ORA-06550: line 9, column 5: PL/SQL: SQL Statement ignored

From Dev

One To Many Relationship In Firebase

From Dev

Doctrine One to Many relationship

From Dev

Seeding one to many relationship

From Dev

Themeing a one to many relationship

From Dev

One to many relationship table

Related Related

  1. 1

    HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

  2. 2

    ORA 00936 Missing Expression

  3. 3

    ora:00936 Missing Expression error

  4. 4

    ORA-00936: missing expression distinct on oracle

  5. 5

    ORA-00936: missing expression - what is the cause?

  6. 6

    ORA-00936: missing expression oracle

  7. 7

    ORA-00936: missing expression in order by case

  8. 8

    SQL Error -- ORA-00936: missing expression

  9. 9

    ORA-00936: Missing Expression Teradata

  10. 10

    ORA-00936: missing expression error when inserting values

  11. 11

    ORA-00936: missing expression, although there seems to be no missing expression (SQL)

  12. 12

    Entity Framework ExecuteStoreCommand gives {"ORA-00936: missing expression"}

  13. 13

    ORA-00936: missing expression bad SQL grammar

  14. 14

    ORA-00936: missing expression while executing in C#.

  15. 15

    ORA-00936: missing expression, although there seems to be no missing expression (SQL)

  16. 16

    ORA-00936: missing expression ORACLE please help me

  17. 17

    Oracle data access error: ORA-00936: missing expression

  18. 18

    ORA-00936: missing expression while using stringbuilder

  19. 19

    getting java.sql.SQLSyntaxErrorException: ORA-00936: missing expression error

  20. 20

    Sql throws 'DBError: ORA-00936: missing expression' when empty expression_list is passed

  21. 21

    retrieve value from One-To-Many relationship Hibernate Without HQL

  22. 22

    hql select query on one to many relationship in spring jpa

  23. 23

    HQL query for Many to Many Explict relationship

  24. 24

    ORA-06550: line 12, column 9: PL/SQL: ORA-00936: missing expression ORA-06550: line 9, column 5: PL/SQL: SQL Statement ignored

  25. 25

    One To Many Relationship In Firebase

  26. 26

    Doctrine One to Many relationship

  27. 27

    Seeding one to many relationship

  28. 28

    Themeing a one to many relationship

  29. 29

    One to many relationship table

HotTag

Archive