You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Ferran Parra <fe...@mubimedia.com> on 2003/04/29 14:26:44 UTC
How delete a rows in indirectionTable??
Hi,
I have a relationship m:n with indirectionTable of objects A and B.
If delete objects of type A automatically deletes the references in
indirection table 'tableAB', but, if delete a object of type B how delete
the rows reference a B in indirection table 'tableAB'??
<class-descriptor
class="com.A"
table="tableA"
>
.........
<collection-descriptor
name="allA"
element-class-ref="com.A"
proxy="true"
refresh="true"
auto-retrieve="true"
auto-update="false"
auto-delete="true"
indirection-table="tableAB"
>
<fk-pointing-to-this-class column="idA"/>
<fk-pointing-to-element-class column="idB"/>
</collection-descriptor>
</class-descriptor>
thanks!!
-------------------------------------------------------
Ferran Parra
ferran_p@mubimedia.com
http://www.mubimedia.com
MUBIMEDIA S.L.
C/ Mallorca, 275, 1r 2a 08008 BCN
Tel: 93 215 21 91 / Fax: 93 215 41 21
-------------------------------------------------------
Re: How delete a rows in indirectionTable??
Posted by Th...@cellzome.com.
Hi Ferran,
I had a look to my mappings and I have a something similar to your
A<--->AB <--->B relationship.
What I did s the following :
A class holds a collection of B with auto-delete = false
B class holds a collection of A with auto-delete = false
If I delete an object A, referenced Bs are not deleted but all records in
table AB referencing A are deleted
If I delete an object B, referenced As are not deleted but all records in
table AB referencing B are deleted
Note that in my case, B holds a collection of A only in order to handle the
automatic deletion: I mean I there is no method B.getAllAs() in interface B
but only a private collection used inernally by OJB.
Hope that can help you,
Thomad
Re: How delete a rows in indirectionTable??
Posted by Ferran Parra <fe...@mubimedia.com>.
Hi thomas
only object A holds a collection of Bs. relation 1:n. what happend when
i delete B?? why no delete the references in the indirectiontable 'tableAB'
of the object A.
ObjectA 1------N ObjectB
<class-descriptor
class="com.A"
table="tableA"
>
.........
<collection-descriptor
name="allB"
element-class-ref="com.B"
proxy="true"
refresh="true"
auto-retrieve="true"
auto-update="false"
auto-delete="true"
indirection-table="tableAB"
>
<fk-pointing-to-this-class column="idA"/>
<fk-pointing-to-element-class column="idB"/>
</collection-descriptor>
</class-descriptor>
----- Original Message -----
From: <Th...@cellzome.com>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, April 29, 2003 4:29 PM
Subject: Re: How delete a rows in indirectionTable??
>
>
>
>
>
> Hi,
>
> I am not 100% sure but I think I remember I did something like that :
>
> An instance of A holds a collection of Bs with auto-delete='true'
> AND
> An instance of B holds a collection of As with auto-delete='true'
>
> Hope that helps,
>
> Thomas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
Re: How delete a rows in indirectionTable??
Posted by Th...@cellzome.com.
Hi,
I am not 100% sure but I think I remember I did something like that :
An instance of A holds a collection of Bs with auto-delete='true'
AND
An instance of B holds a collection of As with auto-delete='true'
Hope that helps,
Thomas
autocommit & rc2
Posted by abo <ab...@online.de>.
Hi,
i switched from 0.9.9 to rc2 and now i'm getting the follwing exception
during my updates:
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] ERROR: Commit
on under
lying connection failed, try to rollback
Can't call commit when autocommit=true
java.sql.SQLException: Can't call commit when autocommit=true
at org.gjt.mm.mysql.Connection.commit(Unknown Source)
my database conf looks like that:
<jdbc-connection-descriptor
jcd-alias="mydefault"
platform="MySQL"
jdbc-level="2.0"
driver="org.gjt.mm.mysql.Driver"
protocol="jdbc"
subprotocol="mysql"
dbalias="//localhost:3306/jContact"
username="jnet"
password="jnet"
batch-mode="false"
useAutoCommit="0"
ignoreAutoCommitExceptions="true" <-- true or false makes no
difference
default-connection="true"
>
when my servlet starts, i get the following from ojb:
[org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] INFO:
Create new
connection
pool:org.apache.ojb.broker.metadata.JdbcConnectionDescriptor@5bb966[
jcd-alias=mydefault
default-connection=true
dbms=MySQL
jdbc-level=2.0
driver=org.gjt.mm.mysql.Driver
protocol=jdbc
sub-protocol=mysql
db-alias=//localhost:3306/jContact
user=jnet
password=*****
eager-release=false
ConnectionPoolDescriptor={whenExhaustedAction=0, maxIdle=-1,
maxActive=21, max
Wait=5000, removeAbandoned=false, numTestsPerEvictionRun=10,
testWhileIdle=false
, minEvictableIdleTimeMillis=600000, testOnReturn=false,
logAbandoned=false, rem
oveAbandonedTimeout=300, timeBetweenEvictionRunsMillis=-1,
testOnBorrow=true}
batchMode=false
useAutoCommit=AUTO_COMMIT_IGNORE_STATE
ignoreAutoCommitExceptions=true
sequenceDescriptor=org.apache.ojb.broker.metadata.SequenceDescriptor@18d
7ace[
sequenceManagerClass=class
org.apache.ojb.broker.util.sequence.SequenceMana
gerHighLowImpl
Properties={grabSize=20}
]
]
if found some posting in the archiv, but they don't really help me.
thanks for any advice
andreas