Hi,

ok, the problem is the reference in ShopTransaction to Transaction.

<reference-descriptor name="super" class-ref="allibo.commerce.Transaction"
auto-retrieve="true" auto-update="true" auto-delete="true">
<foreignkey field-ref="transaction_id"/>
</reference-descriptor>


this means that a ShopTransaction is composed by a ShopTransaction and a Transaction database entries. Because of the flag auto-delete="true" what you are experiencing is absolutely normal.
Also you have 2 entries in different tables for one ShopTransaction instance, deleting the ShopTransaction will remove the entries in the 2 tables.


As Armin wrote in his answer (while i am writing this :) )
your code is also a little strange.

>>>       transaction = new ShopTransaction();
>>>       transaction.setTransaction_id(transaction_id);
>>>       Criteria crit = new Criteria();
>>>       crit.addEqualTo("transaction_id", new Integer(transaction_id));
>>>       Query query = QueryFactory.newQuery(ShopTransaction.class,crit);

1. you should declare transaction as local method variable and not use a class variable
2. you do not need to generate a query (you don't do anything with it anyways in this piece of code)


when deleting an instance (and the primary key is set) OJB should manage to delete the correct object even if it has not been completely materialised, so you do not need to do any query.

bye
danilo

P.S.: in svizzera tutto ok, a parte che qui a zurigo il tempo è uno schifo (varia tra nebbia bassa, nebbia alta, nebbia fitta, nebbia inquinata)


Thank you Danilo for the answer,
I follow the example in the "mapping classes on multiple joined tables" tutorial.
The table ShopTransaction and Transaction are declared as follow.
I've never readed any post on the newsgroup about inheritance problem. I'm the
only working with this feature? Or I'm the only having problems? :-)

<class-descriptor class="allibo.commerce.Transaction" table="fCO_transaction">
    <field-descriptor name="transaction_id" column="transaction_id"
jdbc-type="INTEGER" primarykey="true" autoincrement="true"/>
    <field-descriptor name="transaction_date" column="transaction_date"
jdbc-type="DATE"/>
    <field-descriptor name="grand_total" column="grand_total" jdbc-type="DOUBLE"/>
    <field-descriptor name="discount" column="discount" jdbc-type="DOUBLE"/>
    <field-descriptor name="amount_paid" column="amount_paid" jdbc-type="DOUBLE"/>
</class-descriptor>

<class-descriptor class="allibo.commerce.ShopTransaction" table="v4sco_transaction">
<field-descriptor name="transaction_id" column="transaction_id"
jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> <field-descriptor name="card_saving" column="card_saving" jdbc-type="DOUBLE" />
<field-descriptor name="shop_id" column="shop_id" jdbc-type="INTEGER" />
<reference-descriptor name="super" class-ref="allibo.commerce.Transaction"
auto-retrieve="true" auto-update="true" auto-delete="true">
<foreignkey field-ref="transaction_id"/>
</reference-descriptor> <reference-descriptor name="shop_id" class-ref="allibo.commerce.Shop"
auto-retrieve="true" auto-update="true" auto-delete="true">
<foreignkey field-ref="shop_id"/>
</reference-descriptor> </class-descriptor>


Tutto bene in Svizzera, Danilo?



Hi,

did you declare ShopTransaction as extent-class in the class-descriptor of Transaction? If ShopTransaction and Transaction are to be considered as different entities, then you should not declare ShopTransaction as extent of Transaction in your repository.xml (in Java is Ok). If you did not declare ShopTransaction as extent-class then I guess it is an OJB bug, however somebody with more exp. than me could be of more help.

bye
danilo


Hello,
sometime I'm back with the same question:
I've 2 tables Transaction and ShopTransaction. ShopTransaction extends Transaction.


I've the code
public void apply() {
logger.debug("apply");
logger.debug("transaction_id :" + transaction_id);
transaction = new ShopTransaction(); transaction.setTransaction_id(transaction_id); Criteria crit = new Criteria();
crit.addEqualTo("transaction_id", new Integer(transaction_id));
Query query = QueryFactory.newQuery(ShopTransaction.class,crit);


      broker.beginTransaction();
      broker.delete(transaction);
      broker.commitTransaction();
}

I've the log
310 [main] DEBUG mascheroni.vendite.UCRollbackShopTransaction - transaction_id :2041
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeDelete : [EMAIL PROTECTED]
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeDelete: [EMAIL PROTECTED]: DELETE FROM v4s_transaction WHERE transaction_id = 2022
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeDelete : [EMAIL PROTECTED]
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeDelete: [EMAIL PROTECTED]: DELETE FROM fCO_transaction WHERE transaction_id = 2042


Why?!?!?!!

This time I hope someone could help me





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to