• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

How to map column to a property ?  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I explicitly want to map a column to a preoperty in my value object.

QUERY :

SELECT STATE as STATUS, pInstance.PROCESS_INSTANCE_ID, pInstance.PROCESS_NAME, pInstance.LAST_SAVED FROM ILA_PROCESS_STEPS A JOIN ILA_PROCESS_INSTANCES pInstance
ON A.PROCESS_INSTANCE_ID = pInstance.PROCESS_INSTANCE_ID
WHERE STEP_ID = (SELECT MAX(STEP_ID) FROM ILA_PROCESS_STEPS WHERE PROCESS_INSTANCE_ID = :id)

VALUE OBJECT : ProcessInstance.java

public class ProcessInstance extends Entity implements Serializable {

private String processName;
private Date lastSaved;
private Set<ProcessStep> processSteps;
private Set quotes = null;
private String processState;
private String currentStep;

// GETTER & SETTER are here of course but not added here.

}

MAPPING FILE ProcessInstance.hbm.xml:

<?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 schema="IAO_O">
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class name="com.ing.rcc.db.quote.domain.ProcessInstance" table="ILA_PROCESS_INSTANCES">

<id name="id" type="java.lang.Long">
<column name="PROCESS_INSTANCE_ID" not-null="true" />
<generator class="sequence">
<param name="sequence">S_ILA_PI</param>
</generator>
</id>
<property name="processName" type="java.lang.String" column="PROCESS_NAME" length="64" />
<property name="lastSaved" type="java.sql.Timestamp" column="LAST_SAVED" length="11" />
<!-- Associations -->

<!-- bi-directional one-to-many association to IlaProcessStep -->
<set name="processSteps" lazy="true" inverse="true" cascade="none">
<key>
<column name="PROCESS_INSTANCE_ID" />
</key>
<one-to-many class="com.ing.rcc.db.quote.domain.ProcessStep" />
</set>

<set name="quotes" table="ILA_PROCESS_QUOTES" lazy="true">
<key column="INSTANCE_ID" />
<many-to-many class="com.ing.rcc.db.quote.domain.internal.QuoteData" column="ID" />
</set>
</class>
<sql-query name = "getInstancesIds">
<return alias="pInstance" class="com.ing.rcc.db.quote.domain.ProcessInstance"/>
SELECT MAX(STEP_ID),PROCESS_INSTANCE_ID, STEP_NAME, LAST_SAVED, PROCESS_NAME FROM(
SELECT pInstance.PROCESS_INSTANCE_ID , STEP_ID, step.STEP_NAME , pInstance.PROCESS_NAME, pInstance.LAST_SAVED
FROM ILA_PROCESS_STEPS step , ILA_PROCESS_INSTANCES pInstance
WHERE step.PROCESS_INSTANCE_ID = pInstance.PROCESS_INSTANCE_ID
AND pInstance.PROCESS_NAME LIKE rocessName
AND step.STATE= :state
AND step.STEP_NAME LIKE :stepName
AND pInstance.LAST_SAVED<= :lastSaved)
GROUP BY PROCESS_INSTANCE_ID, LAST_SAVED, STEP_NAME, PROCESS_NAME
</sql-query>

<sql-query name = "getProcessStatus">
<return alias="pInstance" class="com.ing.rcc.db.quote.domain.ProcessInstance"/>
SELECT STATE as STATUS, pInstance.PROCESS_INSTANCE_ID, pInstance.PROCESS_NAME, pInstance.LAST_SAVED FROM ILA_PROCESS_STEPS A JOIN ILA_PROCESS_INSTANCES pInstance
ON A.PROCESS_INSTANCE_ID = pInstance.PROCESS_INSTANCE_ID
WHERE STEP_ID = (SELECT MAX(STEP_ID) FROM ILA_PROCESS_STEPS WHERE PROCESS_INSTANCE_ID = :id)

</sql-query>
</hibernate-mapping>





1. How to execute the named query so as to scroll it like RestultSet in JDBC ?
2.How to map the 'STATUS' column to processState property in ProcessInstance ? In my mapping file i do not have a mapping for this property. When i call 'getProcessStatus' query which the query above, i have all the properties initialized in ProcessInstance but not processState that i want to fill in from the join.

Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!