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 Alexander Prozor <ap...@isd.dp.ua> on 2003/05/29 12:41:49 UTC
anonymous fields
Hello All,
I've tried to use such scheme as described at :
http://cvs.apache.org/viewcvs/db-ojb/xdocs/howto-use-anonymous-keys.xml?rev=HEAD&content-type=text/vnd.viewcvs-markup
but I got such exception :(.
In few words my prog contains 3 classes
class A contains
collection B
collection C
B contains
collection B
C contains
String Name
I put all these classes into a separate tables.
tableA
_id
tableB
_id - I use this field as foreign key for collection from class B, is
it correct? Maybe I have to add additional field to the table B for
having another key?
_idA foreign key for collection from class A
tableC
_id
_idA foreign key for collection from class A
all this fields I've described as anonymous.
in this exception
userDefinitionScreenID - _idA
CompositeControlDefinition - class B
thank you .
> org.apache.ojb.broker.OJBRuntimeException: Incorrect field reference "userDefinitionScreenID" in org.apache.ojb.broker.metadata.ObjectReferenceDescriptor@2966552[cascade delete=false,cascade retrieve=true,cascade store=false,is lazy=false,class of Items=class efi.base.presentation.formdefinition.CompositeControlDefinition]
> at org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFieldDescriptors(Unknown Source)
> at org.apache.ojb.odmg.TransactionImpl.assertFkAssignment(Unknown Source)
> at org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(Unknown Source)
> at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
> at efi.base.persistent.PersistentLayerManager.store(PersistentLayerManager.java:198)
> at efi.base.persistent.PersistentLayerManager.store(PersistentLayerManager.java:143)
> at efi.base.persistent.PersistentLayerManager.main(PersistentLayerManager.java:90)
> rethrown as org.apache.ojb.broker.PersistenceBrokerException: Incorrect field reference "userDefinitionScreenID" in org.apache.ojb.broker.metadata.ObjectReferenceDescriptor@2966552[cascade delete=false,cascade retrieve=true,cascade store=false,is lazy=false,class of Items=class efi.base.presentation.formdefinition.CompositeControlDefinition]
> at org.apache.ojb.odmg.TransactionImpl.assertFkAssignment(Unknown Source)
> at org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(Unknown Source)
> at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
> at efi.base.persistent.PersistentLayerManager.store(PersistentLayerManager.java:198)
> at efi.base.persistent.PersistentLayerManager.store(PersistentLayerManager.java:143)
> at efi.base.persistent.PersistentLayerManager.main(PersistentLayerManager.java:90)
> rethrown as org.apache.ojb.broker.PersistenceBrokerException: Incorrect field reference "userDefinitionScreenID" in org.apache.ojb.broker.metadata.ObjectReferenceDescriptor@2966552[cascade delete=false,cascade retrieve=true,cascade store=false,is lazy=false,class of Items=class efi.base.presentation.formdefinition.CompositeControlDefinition]
> at org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(Unknown Source)
> at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
> at efi.base.persistent.PersistentLayerManager.store(PersistentLayerManager.java:198)
> at efi.base.persistent.PersistentLayerManager.store(PersistentLayerManager.java:143)
> at efi.base.persistent.PersistentLayerManager.main(PersistentLayerManager.java:90)
--
Best regards,
Alexander mailto:apro@isd.dp.ua
Re: anonymous fields
Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Alexander,
You're right. I've not used anonymous keys like this before (although, I
do use them in my app). Maybe I should look further into it!
Sorry I couldn't help-just thought I'd have a go ;)
Cheers,
Raymond
Alexander Prozor wrote:
>Hello Raymond,
>
>I think now if example is correct:
>http://cvs.apache.org/viewcvs/db-ojb/xdocs/howto-use-anonymous-keys.xml?rev=HEAD&content-type=text/vnd.viewcvs-markup
>Desk contains collection of things and reference to the finish .
>It's almost identical to my app :(.
>but for me it doesn't work.
>But only for CompositeControlDefinition
>for DataDefinitionRef all works ok.
>
>
>
>
--
Regards,
Raymond Barlow
Re[3]: anonymous fields
Posted by Alexander Prozor <ap...@isd.dp.ua>.
ohhh,
now it's work again :)
actually I don't understand how it work for now :))))).
another question,
does anybody stored HashMap member?
--
Best regards,
Alexander mailto:apro@isd.dp.ua
Re: Re[2]: anonymous fields
Posted by Brian McCallister <mc...@forthillcompany.com>.
> Hi again,
> actually I was too optimistic,
> it's work without exception , but only for my test ( when I store
> object and then get it by query ).
> when I trying to get previously stored object I got null as value of
> referenced member :(.
>
One thing to be careful of when you see behavior like this is the
caching mechanism. By default OJB does not update cascade/delete
cascade. This is important because the reference for a collection is
stored in the database on the object IN the collection, instead of in
the collection. As long as the PB is retrieving from a cache the
Collection instance belonging to the cached object will be used, but
once it leaves the cache, boom. I haven't had a chance to really
explore the exact behaviors, but I have seen grief and woe from it
myself.
When using the PB API (the only one I have really used) I tend to go
ahead and set up cascades for dependent objects (wholly dependent
entities anyway).
Anyway, one thing I have found helps to find these for me early is to
always flush the cache after writes in my unit tests. In theory you
could change to an empty cache implementation for testing, but flushing
the cache at the end of setUp() is easy and more accurate for what you
want in most cases.
-Brian
Re[2]: anonymous fields
Posted by Alexander Prozor <ap...@isd.dp.ua>.
Hi again,
actually I was too optimistic,
it's work without exception , but only for my test ( when I store
object and then get it by query ).
when I trying to get previously stored object I got null as value of
referenced member :(.
controlRoorRef.
maybe I have to store this reference descriptor in the 'Table' ?
--
Best regards,
Alexander mailto:apro@isd.dp.ua
Re: anonymous fields
Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Guys,
*Phew*, I'm happy to see that I wasn't miles off target!
Keep up the good work people!
Cheers,
Raymond Barlow
Alexander Prozor wrote:
>Hello Brian,
>thank you, but I don't receive any attachments :(.
>and in cvs I sow old xml file :(.
>but that's all bad news :))))
>
>the good news that all works now, after moving reference-descriptor to
>another class ( and adding additional parameter to that class, 'cause
>OJB didn't see anonymous field in this case - and I don't have time
>enough to correct this error :) ).
>
>so - thank you very much.
>
>
>To:Raymond Barlow <rb...@raymanoz.com>
>
>Thank you too :) you were right from very begin :))))
>
>BM> I just put the working code into the howto and sent the patch to the
>BM> developer list, but I figured you might want to correct docs asap - so
>BM> they are attached.
>
>BM> The only real difference (aside from two typos) was the
>BM> reference-descriptor being in the wrong class def (desk references
>BM> finish, not finish references desk as it is in cvs right now - that
>BM> would be a 1:M style).
>
>BM> -Brian
>
>
>
>
Re[4]: anonymous fields
Posted by Alexander Prozor <ap...@isd.dp.ua>.
Hello Brian,
thank you, but I don't receive any attachments :(.
and in cvs I sow old xml file :(.
but that's all bad news :))))
the good news that all works now, after moving reference-descriptor to
another class ( and adding additional parameter to that class, 'cause
OJB didn't see anonymous field in this case - and I don't have time
enough to correct this error :) ).
so - thank you very much.
To:Raymond Barlow <rb...@raymanoz.com>
Thank you too :) you were right from very begin :))))
BM> I just put the working code into the howto and sent the patch to the
BM> developer list, but I figured you might want to correct docs asap - so
BM> they are attached.
BM> The only real difference (aside from two typos) was the
BM> reference-descriptor being in the wrong class def (desk references
BM> finish, not finish references desk as it is in cvs right now - that
BM> would be a 1:M style).
BM> -Brian
--
Best regards,
Alexander mailto:apro@isd.dp.ua
Re: Re[2]: anonymous fields
Posted by Brian McCallister <mc...@forthillcompany.com>.
I just put the working code into the howto and sent the patch to the
developer list, but I figured you might want to correct docs asap - so
they are attached.
The only real difference (aside from two typos) was the
reference-descriptor being in the wrong class def (desk references
finish, not finish references desk as it is in cvs right now - that
would be a 1:M style).
-Brian
Re: Re[2]: anonymous fields
Posted by Brian McCallister <mc...@forthillcompany.com>.
Hmm, am looking at tutorial and your code and found a couple minor
issues with the tutorial (which I wrote, ack!) where I didn't c&p the
finished code snippet into it (hmm, Anakia feature: intelligent include
of code snippets which it magically understands it needs).
Off the top of my head, make the internal_id fields non-anonymous
temporarily to help with debugging and remove a variable.
Will get the tutorial fixed today (probably tonight as I am on the
clock right now), and will look at your problem while doing it.
-Brian
On Thursday, May 29, 2003, at 07:45 AM, Alexander Prozor wrote:
> Hello Raymond,
>
> I think now if example is correct:
> http://cvs.apache.org/viewcvs/db-ojb/xdocs/howto-use-anonymous-
> keys.xml?rev=HEAD&content-type=text/vnd.viewcvs-markup
> Desk contains collection of things and reference to the finish .
> It's almost identical to my app :(.
> but for me it doesn't work.
> But only for CompositeControlDefinition
> for DataDefinitionRef all works ok.
>
>
> --
> Best regards,
> Alexander mailto:apro@isd.dp.ua
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
Re[2]: anonymous fields
Posted by Alexander Prozor <ap...@isd.dp.ua>.
Hello Raymond,
I think now if example is correct:
http://cvs.apache.org/viewcvs/db-ojb/xdocs/howto-use-anonymous-keys.xml?rev=HEAD&content-type=text/vnd.viewcvs-markup
Desk contains collection of things and reference to the finish .
It's almost identical to my app :(.
but for me it doesn't work.
But only for CompositeControlDefinition
for DataDefinitionRef all works ok.
--
Best regards,
Alexander mailto:apro@isd.dp.ua
Re: anonymous fields
Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Alexander,
I think the problem here is your definition of the UserScreenDefinition
class in the mapping file. Basically, you have:
<reference-descriptor
name="rootControlDef"
class-ref="efi.base.presentation.formdefinition.CompositeControlDefinition"
>
<foreignkey field-ref="userDefinitionScreenID"/>
</reference-descriptor>
defined in the mapping, but no corresponding "userDefinitionScreenID"
field also defined in that same class. Methinks you should move that
reference-descriptor out of the definition for UserScreenDefinition, and
put it into both the DataDefinitionRef and CompositeControlDefinition
class descriptors.
See, the field-ref attribute in foreignkey element refers to another
field-descriptor in the same class-descriptor.
Hope this helps,
Cheers,
Raymond Barlow
Alexander Prozor wrote:
>Hello Raymond,
>child classes store in DB successfully.
>problem exists only when I try to persist main class.
>
>
Re[2]: anonymous fields
Posted by Alexander Prozor <ap...@isd.dp.ua>.
Hello Raymond,
child classes store in DB successfully.
problem exists only when I try to persist main class.
--
Best regards,
Alexander mailto:apro@isd.dp.ua
Re[2]: anonymous fields
Posted by Alexander Prozor <ap...@isd.dp.ua>.
Hello Raymond,
sure, I've defined this field in mapping.
there are ddl and repository_user.xml files from this project.
RB> Is "userDefinitionScreenID" a field defined in your mapping? ie. this
RB> has to be the name attribute of a field-descriptor definition. Something
RB> like:
RB> <field-descriptor
RB> name="userDefinitionScreenID"
RB> column="_idA"
RB> jdbc-type="INTEGER"
RB> access="anonymous"/>
RB> Maybe if you post the relevant sections of your repository_user.xml file
RB> it could help identify the problem.
--
Best regards,
Alexander mailto:apro@isd.dp.ua
Re: anonymous fields
Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Alexander
Is "userDefinitionScreenID" a field defined in your mapping? ie. this
has to be the name attribute of a field-descriptor definition. Something
like:
<field-descriptor
name="userDefinitionScreenID"
column="_idA"
jdbc-type="INTEGER"
access="anonymous"/>
Maybe if you post the relevant sections of your repository_user.xml file
it could help identify the problem.
-Raymond Barlow
Alexander Prozor wrote:
>Hello All,
>I've tried to use such scheme as described at :
>http://cvs.apache.org/viewcvs/db-ojb/xdocs/howto-use-anonymous-keys.xml?rev=HEAD&content-type=text/vnd.viewcvs-markup
>
>but I got such exception :(.
>In few words my prog contains 3 classes
>class A contains
>collection B
>collection C
>
>B contains
>collection B
>
>C contains
>String Name
>
>I put all these classes into a separate tables.
>tableA
>_id
>tableB
>_id - I use this field as foreign key for collection from class B, is
>it correct? Maybe I have to add additional field to the table B for
>having another key?
>_idA foreign key for collection from class A
>tableC
>_id
>_idA foreign key for collection from class A
>all this fields I've described as anonymous.
>
>in this exception
>userDefinitionScreenID - _idA
>CompositeControlDefinition - class B
>
>thank you .
>
>
>>org.apache.ojb.broker.OJBRuntimeException: Incorrect field reference "userDefinitionScreenID" in org.apache.ojb.broker.metadata.ObjectReferenceDescriptor@2966552[cascade delete=false,cascade retrieve=true,cascade <snip>
>>