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 Ju...@Bertelsmann.de on 2003/07/14 09:46:03 UTC
autoincrement + cache
Hello!
I have a little more complex problem when inserting objects. I'm not sure
wheter it has to do with my primary keys (some anonymous) or maybe with the
sequence manager or cache I'm using. I'll try to describe:
I have a class ServerVO with an entryID (implemented already in that class).
It has a 1:1 association (reference descriptor) to the class ModulesVO.
ModulesVO holds a List (1:n) of classes of the type ModuleVO which has
already implemented an moduleId. ModuleVO is extended by three further
classes (PingModuleVO, HtppModuleVO, RmiModuleVO). It looks like this:
---------------
| ServerVO |
| int entryId |
---------------
|1
|
|1
------------
| ModulesVO |
-------------
|1
|
|n
----------------
| ModuleVO |
| int moduleId |
----------------
|
-----------------------
| | |
---------- ---------- ---------
| PingVO | | HttpVO | | RmiVO |
---------- ---------- ---------
I have entered in my repository an anonymous field as PK for ModulesVO
(autoincrement="true" primarykey="true" access="anonymous", see repository
below). But it does not increment in the way I expect.
The first stored entry works fine. ModulesVO gets the annonymous id '0'
(referenced in ServerVO). When I want to store the next entry there is only
created an SQL statement that inserts a row for my ServerVO but nothing more
(not for ModulesVO and so on). This next entry gets also a reference to the
same ModulesVO as before!! I never get more then one entry in the table
ModulesVO!
But the strange thing is, that the table content does not correspond with
the content I get when I look it up with a query! That means OJB shows me
content that isn't in the database! Of cause not if I restart my apllication
server. Then the entered data is lost. I also tried to change the cache from
ObjectCacheDefaultImpl to ObjectCacheEmptyImpl but that didn't change a
thing! I hope it is something simple. Or maybe my repository is wrong or the
Sequence manager I'm using? I hope I explained everything comprehensible.
Julia.
<jdbc-connection-descriptor
jcd-alias="default"
default-connection="true"
platform="MySQL"
jdbc-level="2.0"
jndi-datasource-name="java:DemoAppsDB"
username="monitor"
password="password"
eager-release="false"
batch-mode="false"
useAutoCommit="2"
ignoreAutoCommitExceptions="false">
<sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl"/>
</jdbc-connection-descriptor>
<class-descriptor
class="de.arvatosystems.monitoring.business.vo.server.ServerVO"
table="SERVERVO">
<field-descriptor name="entryId" column="ID" jdbc-type="INTEGER"
primarykey="true" autoincrement="false"/>
<field-descriptor name="locale" column="LOCALE" jdbc-type="VARCHAR"
primarykey="true" autoincrement="false"/>
/* some attributes */
<field-descriptor name="modulesId" column="MODULESID"
jdbc-type="INTEGER" primarykey="true"
autoincrement="true" access="anonymous"/>
<reference-descriptor name="modules"
class-ref="de.arvatosystems.monitoring.business.vo.module.ModulesVO">
<foreignkey field-ref="modulesId"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor
class="de.arvatosystems.monitoring.business.vo.module.ModulesVO"
table="MODULESVO">
<field-descriptor name="Id" column="ID" jdbc-type="INTEGER"
autoincrement="true" primarykey="true" access="anonymous"/>
<collection-descriptor name="modules"
element-class-ref="de.arvatosystems.monitoring.business.vo.module.ModuleVO"
orderby="moduleId" sort="ASC">
<inverse-foreignkey field-ref="Id"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor
class="de.arvatosystems.monitoring.business.vo.module.ModuleVO"
table="MODULEVO">
<extent-class
class-ref="de.arvatosystems.monitoring.business.vo.module.PingModuleVO"/>
<extent-class
class-ref="de.arvatosystems.monitoring.business.vo.module.HttpModuleVO"/>
<extent-class
class-ref="de.arvatosystems.monitoring.business.vo.module.RmiModuleVO"/>
<field-descriptor name="Id" column="ENTRYID" jdbc-type="INTEGER"
access="anonymous"
primarykey="true" autoincrement="true"/>
<field-descriptor name="moduleId" column="MODULEID"
jdbc-type="INTEGER" primarykey="true" autoincrement="false"/>
/* some attributes */
</class-descriptor>
<class-descriptor
class="de.arvatosystems.monitoring.business.vo.module.PingModuleVO"
table="PINGMODULEVO">
<field-descriptor name="Id" column="ENTRYID" jdbc-type="INTEGER"
access="anonymous"
primarykey="true" autoincrement="true"/>
<field-descriptor name="moduleId" column="MODULEID"
jdbc-type="INTEGER" primarykey="true" autoincrement="false"/>
/* some attributes */
</class-descriptor>
<class-descriptor
class="de.arvatosystems.monitoring.business.vo.module.HttpModuleVO"
table="HTTPMODULEVO">
<field-descriptor name="Id" column="ENTRYID" jdbc-type="INTEGER"
access="anonymous"
primarykey="true" autoincrement="true"/>
<field-descriptor name="moduleId" column="MODULEID"
jdbc-type="INTEGER" primarykey="true" autoincrement="false"/>
/* some attributes */
</class-descriptor>
<class-descriptor
class="de.arvatosystems.monitoring.business.vo.module.RmiModuleVO"
table="RMIMODULEVO">
<field-descriptor name="Id" column="ENTRYID" jdbc-type="INTEGER"
access="anonymous"
primarykey="true" autoincrement="true"/>
<field-descriptor name="moduleId" column="MODULEID"
jdbc-type="INTEGER" primarykey="true" autoincrement="false"/>
/* some attributes */
</class-descriptor>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: autoincrement + cache
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Julia,
SequenceManagerMySQLImpl is based on Identity columns
and is not extent aware (using different tables for extents, see
javadoc)
> ---------- ---------- ---------
> | PingVO | | HttpVO | | RmiVO |
> ---------- ---------- ---------
The generated ids must be unique across these three tables. When
using Identity columns they aren't.
If possible don't use Identity columns. The OJB concept of using
Identity objects of persistent objects (OJB handle unique
Identity objects of persistent objects before they writen in
the database) clash a bit with the DB identity
column concept. Let OJB handle the id generation
by using another sequence manager implementation
http://db.apache.org/ojb/sequencemanager.html
Or use the same table for PingVO, ... objects - but keep in
mind SequenceManagerMySQLImpl is "Not thoroughly tested"
and a little bit outdated.
With the next release (current CVS) you can find a new SequenceManager
implementation SequenceManagerNativeImpl which supports native identity
columns (replacement for outdated SequenceManagerMySQLImpl). But this
implementation isn't extent aware too.
regards,
Armin
----- Original Message -----
From: <Ju...@Bertelsmann.de>
To: <oj...@db.apache.org>
Sent: Monday, July 14, 2003 9:46 AM
Subject: autoincrement + cache
> Hello!
>
> I have a little more complex problem when inserting objects. I'm not
sure
> wheter it has to do with my primary keys (some anonymous) or maybe
with the
> sequence manager or cache I'm using. I'll try to describe:
>
> I have a class ServerVO with an entryID (implemented already in that
class).
> It has a 1:1 association (reference descriptor) to the class
ModulesVO.
> ModulesVO holds a List (1:n) of classes of the type ModuleVO which has
> already implemented an moduleId. ModuleVO is extended by three further
> classes (PingModuleVO, HtppModuleVO, RmiModuleVO). It looks like this:
>
> ---------------
> | ServerVO |
> | int entryId |
> ---------------
> |1
> |
> |1
> ------------
> | ModulesVO |
> -------------
> |1
> |
> |n
> ----------------
> | ModuleVO |
> | int moduleId |
> ----------------
> |
> -----------------------
> | | |
> ---------- ---------- ---------
> | PingVO | | HttpVO | | RmiVO |
> ---------- ---------- ---------
>
> I have entered in my repository an anonymous field as PK for ModulesVO
> (autoincrement="true" primarykey="true" access="anonymous", see
repository
> below). But it does not increment in the way I expect.
> The first stored entry works fine. ModulesVO gets the annonymous id
'0'
> (referenced in ServerVO). When I want to store the next entry there is
only
> created an SQL statement that inserts a row for my ServerVO but
nothing more
> (not for ModulesVO and so on). This next entry gets also a reference
to the
> same ModulesVO as before!! I never get more then one entry in the
table
> ModulesVO!
>
> But the strange thing is, that the table content does not correspond
with
> the content I get when I look it up with a query! That means OJB shows
me
> content that isn't in the database! Of cause not if I restart my
apllication
> server. Then the entered data is lost. I also tried to change the
cache from
> ObjectCacheDefaultImpl to ObjectCacheEmptyImpl but that didn't change
a
> thing! I hope it is something simple. Or maybe my repository is wrong
or the
> Sequence manager I'm using? I hope I explained everything
comprehensible.
>
> Julia.
>
>
> <jdbc-connection-descriptor
> jcd-alias="default"
> default-connection="true"
> platform="MySQL"
> jdbc-level="2.0"
> jndi-datasource-name="java:DemoAppsDB"
> username="monitor"
> password="password"
> eager-release="false"
> batch-mode="false"
> useAutoCommit="2"
> ignoreAutoCommitExceptions="false">
> <sequence-manager
>
className="org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl"
/>
> </jdbc-connection-descriptor>
>
>
>
> <class-descriptor
> class="de.arvatosystems.monitoring.business.vo.server.ServerVO"
> table="SERVERVO">
> <field-descriptor name="entryId" column="ID" jdbc-type="INTEGER"
> primarykey="true" autoincrement="false"/>
> <field-descriptor name="locale" column="LOCALE" jdbc-type="VARCHAR"
> primarykey="true" autoincrement="false"/>
> /* some attributes */
> <field-descriptor name="modulesId" column="MODULESID"
> jdbc-type="INTEGER" primarykey="true"
> autoincrement="true" access="anonymous"/>
> <reference-descriptor name="modules"
> class-ref="de.arvatosystems.monitoring.business.vo.module.ModulesVO">
> <foreignkey field-ref="modulesId"/>
> </reference-descriptor>
> </class-descriptor>
>
> <class-descriptor
> class="de.arvatosystems.monitoring.business.vo.module.ModulesVO"
> table="MODULESVO">
> <field-descriptor name="Id" column="ID" jdbc-type="INTEGER"
> autoincrement="true" primarykey="true" access="anonymous"/>
> <collection-descriptor name="modules"
>
element-class-ref="de.arvatosystems.monitoring.business.vo.module.Module
VO"
> orderby="moduleId" sort="ASC">
> <inverse-foreignkey field-ref="Id"/>
> </collection-descriptor>
> </class-descriptor>
>
> <class-descriptor
> class="de.arvatosystems.monitoring.business.vo.module.ModuleVO"
> table="MODULEVO">
> <extent-class
>
class-ref="de.arvatosystems.monitoring.business.vo.module.PingModuleVO"/
>
> <extent-class
>
class-ref="de.arvatosystems.monitoring.business.vo.module.HttpModuleVO"/
>
> <extent-class
>
class-ref="de.arvatosystems.monitoring.business.vo.module.RmiModuleVO"/>
> <field-descriptor name="Id" column="ENTRYID" jdbc-type="INTEGER"
> access="anonymous"
> primarykey="true" autoincrement="true"/>
> <field-descriptor name="moduleId" column="MODULEID"
> jdbc-type="INTEGER" primarykey="true" autoincrement="false"/>
> /* some attributes */
> </class-descriptor>
>
> <class-descriptor
> class="de.arvatosystems.monitoring.business.vo.module.PingModuleVO"
> table="PINGMODULEVO">
> <field-descriptor name="Id" column="ENTRYID" jdbc-type="INTEGER"
> access="anonymous"
> primarykey="true" autoincrement="true"/>
> <field-descriptor name="moduleId" column="MODULEID"
> jdbc-type="INTEGER" primarykey="true" autoincrement="false"/>
> /* some attributes */
> </class-descriptor>
>
> <class-descriptor
> class="de.arvatosystems.monitoring.business.vo.module.HttpModuleVO"
> table="HTTPMODULEVO">
> <field-descriptor name="Id" column="ENTRYID" jdbc-type="INTEGER"
> access="anonymous"
> primarykey="true" autoincrement="true"/>
> <field-descriptor name="moduleId" column="MODULEID"
> jdbc-type="INTEGER" primarykey="true" autoincrement="false"/>
> /* some attributes */
> </class-descriptor>
>
> <class-descriptor
> class="de.arvatosystems.monitoring.business.vo.module.RmiModuleVO"
> table="RMIMODULEVO">
> <field-descriptor name="Id" column="ENTRYID" jdbc-type="INTEGER"
> access="anonymous"
> primarykey="true" autoincrement="true"/>
> <field-descriptor name="moduleId" column="MODULEID"
> jdbc-type="INTEGER" primarykey="true" autoincrement="false"/>
> /* some attributes */
> </class-descriptor>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org