hello paran0rmal,
The mappings looks as follows:
Code:
<hibernate-mapping schema="generalledger">
<class name="Account" table="Account" dynamic-insert="true" dynamic-update="true">
<bag name="credits" inverse="true" access="field" where="type='C'">
<key column="account"/>
<one-to-many class="CreditEntry"/>
</bag>
<bag name="debits" inverse="true" access="field" where="type='D'">
<key column="account"/>
<one-to-many class="DebitEntry" />
</bag>
</class>
</hibernate-mapping>
<hibernate-mapping schema="generalledger">
<class name="AccountEntry" table="accountentry" dynamic-insert="true" dynamic-update="true">
<discriminator column="type" type="string"/>
<many-to-one name="period" cascade="none"/>
<many-to-one name="account" class="Account" column="account"
cascade="none" not-null="true"/>
<subclass name="net.tradestream.generalledger.domain.gl.CreditEntry" discriminator-value="C">
</subclass>
<subclass name="net.tradestream.generalledger.domain.gl.DebitEntry" discriminator-value="D">
</subclass>
</class>
</hibernate-mapping>
<hibernate-mapping schema="generalledger">
<class name="Period" table="Period" dynamic-insert="true" dynamic-update="true">
<property name="sequence" column="sequence" type="long"/>
</class>
</hibernate-mapping>
<hibernate-mapping schema="generalledger">
<class name="AccountTransaction" table="AccountTransaction" dynamic-insert="true" dynamic-update="true" >
<many-to-one name="period" column="period" cascade="none" not-null="true"/>
<bag name="entries" access="field" cascade="all-delete-orphan" inverse="true">
<key column="accountTransaction"/>
<one-to-many class="AccountEntry"/>
</bag>
</class>
</hibernate-mapping>
I am trying to change the account to use a HashMap for the debits and credits and not as List. The HashMap should be keyed by the period in which the entry was created.
The Transaction is created and the entries are added to it and the Account. Only when the Transaction is persisted are the AccountEntries persisted.
I have only been able to map HashMap<Period, CreditEntry> and HashMap<Period, DebitEntry>, but obviously I need a list.
I hope that makes it a bit clearer, if not please let me know and I will post more information.