How to use formula?
I use the attribute 'formula' to subselect the numbers of all rows in the 'property' tag, it runs smoothly.
I also want to sum some two colomns values, but I don't know how to write the expression. The following is the mapping I
wrote and the exception:
Caused by: java.sql.SQLException: Unknown column 'jobs0_.minLvl' in 'field list'
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Thu Sep 22 15:24:37 CST 2005 -->
<hibernate-mapping package="com.test">
<class name="Jobs" table="jobs">
<id name="jobId" column="job_id" type="short">
<generator class="increment" />
</id>
<property name="jobDesc" column="job_desc" type="string"
not-null="true" />
<property name="minLvl" column="min_lvl" type="short"
not-null="true" />
<property name="maxLvl" column="max_lvl" type="short"
not-null="true" />
<property name="twovalues" type="short"
formula="( minLvl+maxLvl )" />
<!--
formula="( select COUNT(*) from Jobs )" />
--> <bag name="employeeSet" cascade="all" inverse="true">
<key column="job_id" />
<one-to-many class="Employee" />
</bag>
</class>
</hibernate-mapping>
|