b wrote:
>>>I've the code >>>public void apply() { >>> logger.debug("apply"); >>> logger.debug("transaction_id :" + transaction_id); >>> transaction = new ShopTransaction(); >>>transaction.setTransaction_id(transaction_id);
Why did you instantiate new ShopTransaction for deleting??
Criteria >>>crit = new Criteria(); >>> crit.addEqualTo("transaction_id", new Integer(transaction_id)); >>> Query query = QueryFactory.newQuery(ShopTransaction.class,crit); >>>
Where did you lookup ShopTransaction? missing transaction = broker.getObjectByQuery(query);
>>> 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
hmm, something wrong with your pk handling? Seems given ShopTransaction object has 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
Seems ShopTransaction 2022 had a reference to Transaction 2042
I don't think (hope) it's a OJB problem.
Could you add some log before delete ShopTransaction to see which id was involved?
>>> broker.beginTransaction(); ==> System.out.println("shop: " + transaction) >>> broker.delete(transaction); >>> broker.commitTransaction();
regards, Armin
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]
-- Danilo Tommasina, Dipl. Ing. FH Telecom Software Engineer RCS Riskmanagement Concepts Systems AG Technoparkstrasse 1 CH-8005 Zuerich T: +41 1 445 29 08 [EMAIL PROTECTED] www.risksys.com
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]