You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Peter Karich <pe...@yahoo.de> on 2007/08/10 16:03:46 UTC

Unregistered Objects

Hallo,

as discussed here [1] and there [2].
I am seeking for a solution where the following works:

Room r = new Room();
getContext().registerNewObject(r);

Meeting m = new Meeting();
r.addMeeting(m);  //[3]

I get heavy memory problems in my calculations, while doing the 
following procedure 100,000 times: I create a meeting, calculate sth. 
and remove it. Cayenne forces me to register all the 'meetings' and will 
reference them although I don't need them anylonger. But I don't know 
when I won't need them.

So one solution comes from Mike Kienenberger as discussed before and 
another solution could be to create sth. like a readonly context, where 
I could copy the results in a normal DataContext if I am done. So can I 
simply put the objects into the ObjectStore by a WeakReference or should 
I know more about the internals. (I think I should!)
May be a readonly context could even improve performance, because of the 
nonexistent 'registering' overhead.


Now my questions are:
1. Is there already a (similar) solution for the ReadOnlyContext?
2. Will cayenne implement Mike Kienenberger's solution? Or others? Can I 
open a JIRA issue/feature request [3]?
3. Are there other ORM's that solve this. (Not worth to exchange, but 
worth to know :-)
4. Could JPA help me here or will cayenne silently 'add the meetings' as 
in normal cayenne setup?


Bye,
Peter.


[1]
http://objectstyle.org/cayenne/lists/cayenne-user/2007/03/0181.html

[2]
http://objectstyle.org/cayenne/lists/cayenne-user/2007/04/0054.html

[3]
Where the user can decide if a context does then
"throw an explicit exception", "add m silently and make it persistent" 
or "add m silently, but don't make persistent", if an unregistered 
object like 'm' will be added to a registered one like 'p' (or the other 
way around)
And without registering one object (2 unregistered) cayenne shouldn't 
throw NPE's.

Re: Unregistered Objects

Posted by Mike Kienenberger <mk...@gmail.com>.
All of my information was from the JPA spec doc:

ejb-3_0-fr-spec-persistence.pdf

You can probably grab a copy from here:

http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html

On 8/13/07, Peter Karich <pe...@yahoo.de> wrote:
> Mike Kienenberger schrieb:
> > I may be wrong but from my reading, I seem to recall that JPA supports
> > unregistered objects, so JPA may be able to help you here.   I think
> > JPA also supports non-persisted objects in the class hierarchy, so you
> > might even be able to define a TemporaryMeeting subclass (or
> > superclass) of Meeting that would never be persisted.
>
> Thank you Mike! That would be very very good :-)
> Does any body has more information on that subject?
>
> Peter.
>

Re: Unregistered Objects

Posted by Peter Karich <pe...@yahoo.de>.
Mike Kienenberger schrieb:
> I may be wrong but from my reading, I seem to recall that JPA supports
> unregistered objects, so JPA may be able to help you here.   I think
> JPA also supports non-persisted objects in the class hierarchy, so you
> might even be able to define a TemporaryMeeting subclass (or
> superclass) of Meeting that would never be persisted.

Thank you Mike! That would be very very good :-)
Does any body has more information on that subject?

Peter.

Re: Unregistered Objects

Posted by Mike Kienenberger <mk...@gmail.com>.
I may be wrong but from my reading, I seem to recall that JPA supports
unregistered objects, so JPA may be able to help you here.   I think
JPA also supports non-persisted objects in the class hierarchy, so you
might even be able to define a TemporaryMeeting subclass (or
superclass) of Meeting that would never be persisted.

On 8/10/07, Peter Karich <pe...@yahoo.de> wrote:
> Hallo,
>
> as discussed here [1] and there [2].
> I am seeking for a solution where the following works:
>
> Room r = new Room();
> getContext().registerNewObject(r);
>
> Meeting m = new Meeting();
> r.addMeeting(m);  //[3]
>
> I get heavy memory problems in my calculations, while doing the
> following procedure 100,000 times: I create a meeting, calculate sth.
> and remove it. Cayenne forces me to register all the 'meetings' and will
> reference them although I don't need them anylonger. But I don't know
> when I won't need them.
>
> So one solution comes from Mike Kienenberger as discussed before and
> another solution could be to create sth. like a readonly context, where
> I could copy the results in a normal DataContext if I am done. So can I
> simply put the objects into the ObjectStore by a WeakReference or should
> I know more about the internals. (I think I should!)
> May be a readonly context could even improve performance, because of the
> nonexistent 'registering' overhead.
>
>
> Now my questions are:
> 1. Is there already a (similar) solution for the ReadOnlyContext?
> 2. Will cayenne implement Mike Kienenberger's solution? Or others? Can I
> open a JIRA issue/feature request [3]?
> 3. Are there other ORM's that solve this. (Not worth to exchange, but
> worth to know :-)
> 4. Could JPA help me here or will cayenne silently 'add the meetings' as
> in normal cayenne setup?
>
>
> Bye,
> Peter.
>
>
> [1]
> http://objectstyle.org/cayenne/lists/cayenne-user/2007/03/0181.html
>
> [2]
> http://objectstyle.org/cayenne/lists/cayenne-user/2007/04/0054.html
>
> [3]
> Where the user can decide if a context does then
> "throw an explicit exception", "add m silently and make it persistent"
> or "add m silently, but don't make persistent", if an unregistered
> object like 'm' will be added to a registered one like 'p' (or the other
> way around)
> And without registering one object (2 unregistered) cayenne shouldn't
> throw NPE's.
>

Re: Unregistered Objects

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Aug 10, 2007, at 10:03 AM, Peter Karich wrote:

>
> I get heavy memory problems in my calculations, while doing the  
> following procedure 100,000 times: I create a meeting, calculate  
> sth. and remove it. Cayenne forces me to register all the  
> 'meetings' and will reference them although I don't need them  
> anylonger. But I don't know when I won't need them.

Cayenne 3.0 does not retain DataContext objects that are not  
referenced by the user code. Try 3.0 M1 - this could be all you need.

Andrus