Hibernate version:1.2.0.4000
I have two classes - JobProcess and ProcessStepTemplate
Mapping documents:
<class name="PB.DPPConnector.DFWorks.JobProcess, PB.DPPConnector.DFWorks" table="PROCESS_STEP_REQUEST">
<id name="Id" column="ID">
<generator class="native" />
</id>
<property name="Name" column="STEPID" />
<property name="TotalCount" column="TOTALPIECES" />
<property name="FinishedCount" column="PIECESFINISHED" />
<many-to-one name="ProcessStepTemplate" column="PSTEMPLATEIDFK" class="PB.DPPConnector.DFWorks.ProcessStepTemplate, PB.DPPConnector.DFWorks"
not-null="true" />
</class>
<class name="PB.DPPConnector.DFWorks.ProcessStepTemplate, PB.DPPConnector.DFWorks" table="PROCESS_APPLICABILITY">
<id name="Id" column="ID">
<generator class="native" />
</id>
<many-to-one name="JobType" column="JOBTYPEIDFK" class="PB.DPPConnector.DFWorks.JobType, PB.DPPConnector.DFWorks" unique="true" />
</class>
Now I want to fetch them using a sql query, which is like -
Code:
string select = "select jp.ID, jp.STEPID, jp.TOTALPIECES, jp.PIECESFINISHED, jp.PSTEMPLATEIDFK, pst.ID";
string from = "from PROCESS_STEP_REQUEST {jp}, PROCESS_STEP_TEMPLATE {pst}";
string where = "where jp.PSTEMPLATEIDFK = pst.ID and {jp}.MAILRUNIDFK = ?";
string query = String.Format("{0} {1} {2}", select, from, where);
IList<JobProcess> processes = session.CreateSQLQuery(query)
.AddEntity("jp", typeof(JobProcess))
.AddJoin("pst", "jp.ProcessStepTemplate")
.SetParameter(0, jobTicket.Id).List<JobProcess>();
but I get the following error - "could not execute query ... Positional parameters 0 1000001".
I've tried to write this query in many ways, but I've failed. I have to use a SQL query because one of my entities is not mapped to any of the tables (because no such table is present).
Please help. I tried searching the forum too, but could not resolve my problem.
Thx in advance.