Hibernate version:
2.1.8
Mapping documents:
Domain object:
/**
* The total price per stock of the invoice lines.
*/
private double totalPricePerStock;
/**
* @param totalPricePerStock The totalPricePerStock to set.
*/
public final void setTotalPricePerStock(final double totalPricePerStock) {
this.totalPricePerStock = totalPricePerStock;
}
/**
* @hibernate.property name="totalPricePerStock"
* formula="FAR_AANTAL*FAR_PRIJS_PER_STUK" type="double"
*
* @return Returns the totalPricePerStock.
*/
public final double getTotalPricePerStock() {
return totalPricePerStock;
}
From generated hbm document:
<property
name="totalPricePerStock"
type="double"
update="true"
insert="true"
column="totalPricePerStock"
/>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Why it does not generate the totalPricePerStock field like a formula into the hbm document ?
If i use this field into a HQL query the generated SQL is:
[14:35:25.739] DEBUG Settings_zipper - Testing query invoice.getBudgetaryPriceByOrgAndPeriod : net.sf.hibernate.impl.QueryImpl@2e34bf
[14:35:25.755] DEBUG SessionImpl - find:
select inv.invoicePeriod, invl.totalPricePerStock from ro.isdc.idcf.resources.zipper.Order as ord, ro.isdc.idcf.resources.zipper.InvoiceLines as invl, ro.isdc.idcf.resources.zipper.Invoice as inv where ord.organization.id = ? and ord.orderType.changeBudget = 'N' and invl.order = ord.id and inv.id = invl.key.invoice and inv.invoicePeriod IN (:p_periods0_, :p_periods1_) group by inv.invoicePeriod order by inv.invoicePeriod
[14:35:25.755] DEBUG QueryParameters - parameters: [90001456]
[14:35:25.755] DEBUG QueryParameters - named parameters: {p_periods1_=502, p_periods0_=501}
[14:35:25.755] DEBUG QueryTranslator - compiling query
[14:35:25.786] DEBUG SessionImpl - flushing session
[14:35:25.786] DEBUG SessionImpl - Flushing entities and processing referenced collections
[14:35:25.786] DEBUG SessionImpl - Processing unreferenced collections
[14:35:25.786] DEBUG SessionImpl - Scheduling collection removes/(re)creates/updates
[14:35:25.786] DEBUG SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
[14:35:25.786] DEBUG SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
[14:35:25.786] DEBUG SessionImpl - Dont need to execute flush
[14:35:25.786] DEBUG QueryTranslator - HQL:
select inv.invoicePeriod, invl.totalPricePerStock from ro.isdc.idcf.resources.zipper.Order as ord, ro.isdc.idcf.resources.zipper.InvoiceLines as invl, ro.isdc.idcf.resources.zipper.Invoice as inv where ord.organization.id = ? and ord.orderType.changeBudget = 'N' and invl.order = ord.id and inv.id = invl.key.invoice and inv.invoicePeriod IN (:p_periods0_, :p_periods1_) group by inv.invoicePeriod order by inv.invoicePeriod
[14:35:25.786] DEBUG QueryTranslator - SQL: select invoice2_.FAC_FACTUURPERIODE as x0_0_, invoicelin1_.totalPricePerStock as x1_0_ from VER_VERKOPEN order0_, FAR_FACTUURREGELS invoicelin1_, FAC_FACTUREN invoice2_, ORS_ORDERSOORTEN ordertype3_ where (order0_.VER_0VESTIGING=? )and(ordertype3_.ORS_BUDGET_AFBOEKEN='N' and order0_.VER_ORDERSOORT=ordertype3_.ORS_ORDERSOORT and order0_.VER_INVOERFASE=ordertype3_.ORS_INVOERFASE)and(invoicelin1_.FAR_0VERKOOP=order0_.VER_VERKOOP )and(invoice2_.FAC_FACTUUR=invoicelin1_.FAR_FACTUUR )and(invoice2_.FAC_FACTUURPERIODE IN(? , ?)) group by invoice2_.FAC_FACTUURPERIODE order by invoice2_.FAC_FACTUURPERIODE
[14:35:25.786] DEBUG BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
[14:35:25.786] DEBUG DriverManagerConnectionProvider - total checked-out connections: 0
[14:35:25.786] DEBUG DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
[14:35:25.786] DEBUG SQL - select invoice2_.FAC_FACTUURPERIODE as x0_0_, invoicelin1_.totalPricePerStock as x1_0_ from VER_VERKOPEN order0_, FAR_FACTUURREGELS invoicelin1_, FAC_FACTUREN invoice2_, ORS_ORDERSOORTEN ordertype3_ where (order0_.VER_0VESTIGING=? )and(ordertype3_.ORS_BUDGET_AFBOEKEN='N' and order0_.VER_ORDERSOORT=ordertype3_.ORS_ORDERSOORT and order0_.VER_INVOERFASE=ordertype3_.ORS_INVOERFASE)and(invoicelin1_.FAR_0VERKOOP=order0_.VER_VERKOOP )and(invoice2_.FAC_FACTUUR=invoicelin1_.FAR_FACTUUR )and(invoice2_.FAC_FACTUURPERIODE IN(? , ?)) group by invoice2_.FAC_FACTUURPERIODE order by invoice2_.FAC_FACTUURPERIODE
[14:35:25.786] DEBUG BatcherImpl - preparing statement
[14:35:25.817] DEBUG IntegerType - binding '90001456' to parameter: 1
[14:35:25.849] DEBUG IntegerType - binding '502' to parameter: 3
[14:35:25.849] DEBUG IntegerType - binding '501' to parameter: 2
[14:35:25.849] DEBUG JDBCExceptionReporter - SQL Exception
java.sql.SQLException: ORA-00904: "INVOICELIN1_"."TOTALPRICEPERSTOCK": invalid identifier
So, into the generated SQL I have the totalPricePerStock instead of the
FAR_AANTAL*FAR_PRIJS_PER_STUK.
|