Good morning my 5 reader :) , I'm sorry if this is a question already asked, but I still cant find a solution:
I have an object mapped like this:
Code:
<hibernate-mapping>
<class name="SipCall" table="RAW_SIP" schema="VOIP">
<id name="id" type="big_decimal">
<column name="ID" precision="20" scale="0"/>
<generator class="assigned" />
</id>
<property name="idGroup" type="int">
<column name="ID_GROUP" precision="9" scale="0" />
</property>
...
[cut]... many properties follows [/cut]
...
<property name="rtpCalledPacketExpected" type="long">
<column name="RTP_CALLED_PACKET_EXPECTED" precision="10" scale="0" />
</property>
<property name="rtpCalledPacketLost" type="long">
<column name="RTP_CALLED_PACKET_LOST" precision="10" scale="0" />
</property>
...
etc...
My object is quite big, having 192 properties and at this moment the readers left are probably fallen down to 3 :)
When I do createQuery(SipCall.class), I add Restrictions dinamically, based on user chooice, so, for example, user choose "RTP CALLED PACKET LOST" in the web form and I can dinamically append ".add(Restrictions.eq("rtpCalledPacketLost",userInputValue))" to my query, this way all is dynamic and I can avoid having 192 "if then" in the code
So all of this sounds normal, but what if I need to add a restriction on an arithmetic calculations like, for example:
percent of packet lost = rtpCalledPacketLost/rtpCalledPacketExpected
I thought I could add a property like
Code:
<property name="rtpPercentPacketLost" type="long">
<column name="RTP_CALLED_PACKET_LOST/RTP_CALLED_PACKET_EXPECTED" precision="10" scale="0" />
</property>
but, of course, it doesnt work, so, my dear only one left reader :) finally my question is:
can I map a property to do some math on sql columns ??
thanks in advance