You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com> on 2009/08/03 12:09:03 UTC

Custom proxy : idea review needed

Hi,

My question is "is there simpler things to do ?"
Please, review that idea and don't hesitate to comment ...

Step 1 : I want partial object, not hashtables. It could be a Person  
with only some attributes having values.
this concern not only @Basic attribute but also any relational  
attributes like @ManyToOne, ...
=> I used fetch plan and it works fine.

Step 2 : I'm using an Apache lib via a third party framework that  
explore all accessors (beanutils).
Unfortunatly, unretreived attributes came with a proxy.
As a consequence, all unreitreived attributes are now retreived  
wasting all the benefit of having used fetch plan ...

Step 3 : I first try to get rid of that proxies but without success,
so I though I could just have my own proxy that could subclass the  
OpenJPA default proxy
and just ensure in my subclass that when I need no proxy, the default  
behavior is bypassed.

What do you think about that idea ?

Re: Why OpenJPA rocks. was: Custom proxy : idea review needed

Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
On Aug 6, 2009, at 00:16 , Pinaki Poddar wrote:

>
> Hi,
>  I have not come across vertical and horizontal analogy w.r.t. fetch  
> plan -
> and it did provide a neat imagery. But this analogy still refers to  
> a 'boxy'
> or tabular world view popularized (or monopolized) by RDBMS.
Yes I fully agree.
> If one thinks 'out of the box', then
>      a) a query for objects select a list of 'root nodes' {R:r}
> and b) the query fetches a graph rooted in each node r.
> And c) fetch plans are a specification to define a sub-graph on  
> closure of
> r.
>
This is exactly that !

> For recursive parent-child relationship, for example, one can  
> specify a
> Fetch Plan to traverse the child-to-parent a fixed number of times  
> -- a
> notion neither supported in SQL nor in JPA based FETCH JOIN.
>
>
>
>
> Jean-Baptiste BRIAUD -- Novlog wrote:
>>
>> Any comments on that vision ?
>> On Aug 5, 2009, at 16:33 , Jean-Baptiste BRIAUD -- Novlog wrote:
>>
>>> The need is simple : get trees of partially valuated business object
>>> instances from the "big graph" of possible linked business classes.
>>> The fact came from old SQooL (a bad IT joke from old school and old
>>> SQL) :
>>> 1. only get back from DB what you need.
>>> 2. the other thing is to try to make as few trip to the DB as
>>> possible. One request is better than several.
>>> DB will optimized if the request look like complex.
>>> In other words, let the DB optimize for you, as much as possible.
>>>
>>> So, I'm in Java, I want instances of my business classes but with
>>> only attributes I need (rule 1).
>>> That attributes that had to be taken or left from the DB can be
>>> @Basic one or any other relational one like @ManyToOne,  
>>> @OneToOne, ...
>>> I also want to express that in one request ideally (point 2).
>>> I let the Java framework optimize for me and send as few SQL request
>>> as possible.
>>>
>>> Basically, there is 2 "filters" to distinguish :
>>> * vertical one that can filter several "lines" from the million in
>>> the table : this is the WHERE clause
>>> * horizontal one that can bring back only certain column : this is
>>> the SELECT clause
>>> both are usefull.
>>>
>>> Vertical one are well taken into account by all the frameworks I had
>>> to use.
>>>
>>> Horizontal one had been poorly taken into account by other
>>> frameworks I had to use.
>>> I can get back with some instances (vertical filter) but with all
>>> attributes (bad horizontal filter).
>>> Or I can have both working but the result is an array of hash tables
>>> and I need instances of my business classes.
>>> This is really bad since that hash map's keys are not the attribute
>>> (field) name but the position in the SELECT clause !
>>> Meta information is just lost in translation and nobody care :-)
>>>
>>> Some framework are able to handle poorly (better than not handling
>>> at all) horizontal filtering via eager or lazy loading but this only
>>> concern relational attributes excluding @Basic one and also, most of
>>> the time this can't be set dynamicaly and you have to provide as a
>>> developper specific constructor of your business class.
>>> All that horizontal filtaring has to be set statically via
>>> annotation or more painfully via XML but not dynamically.
>>> At the end, it is a lot of work for the developper for not having
>>> real horizontal filter.
>>>
>>> As a conclusion, and as far as I know, OpenJPA was the only one able
>>> to give me back some (efficient vertical filter) instances of my
>>> business classes partially valuated depending on my needs (efficient
>>> horizontal filter) both filters can be specified entirely
>>> dynamically if I want but it is also statically via annotation.
>>> This had been possible with only one request.
>>>
>>> Without any reference to an old OO DB, OpenJPA is a precious
>>> gemstone !
>>>
>>> On Aug 5, 2009, at 15:36 , Pinaki Poddar wrote:
>>>
>>>>
>>>> Hi,
>>>>> I can tell OpenJPA rocks, what I did had been tested impossible to
>>>>> do with
>>>>> other frameworks.
>>>>
>>>> Good to know that you found OpenJPA useful.
>>>>
>>>> Will you please elaborate which aspects/features of OpenJPA are
>>>> distinct
>>>> from other frameworks in your view?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----
>>>> Pinaki
>>>> -- 
>>>> View this message in context:
>>>> http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3391748.html
>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>>>
>>>
>>>
>>
>>
>>
>
>
> -----
> Pinaki
> -- 
> View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3395110.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Why OpenJPA rocks. was: Custom proxy : idea review needed

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
  I have not come across vertical and horizontal analogy w.r.t. fetch plan -
and it did provide a neat imagery. But this analogy still refers to a 'boxy'
or tabular world view popularized (or monopolized) by RDBMS. 
If one thinks 'out of the box', then 
      a) a query for objects select a list of 'root nodes' {R:r}
and b) the query fetches a graph rooted in each node r. 
And c) fetch plans are a specification to define a sub-graph on closure of
r. 

For recursive parent-child relationship, for example, one can specify a
Fetch Plan to traverse the child-to-parent a fixed number of times -- a
notion neither supported in SQL nor in JPA based FETCH JOIN.




Jean-Baptiste BRIAUD -- Novlog wrote:
> 
> Any comments on that vision ?
> On Aug 5, 2009, at 16:33 , Jean-Baptiste BRIAUD -- Novlog wrote:
> 
>> The need is simple : get trees of partially valuated business object  
>> instances from the "big graph" of possible linked business classes.
>> The fact came from old SQooL (a bad IT joke from old school and old  
>> SQL) :
>> 1. only get back from DB what you need.
>> 2. the other thing is to try to make as few trip to the DB as  
>> possible. One request is better than several.
>> DB will optimized if the request look like complex.
>> In other words, let the DB optimize for you, as much as possible.
>>
>> So, I'm in Java, I want instances of my business classes but with  
>> only attributes I need (rule 1).
>> That attributes that had to be taken or left from the DB can be  
>> @Basic one or any other relational one like @ManyToOne, @OneToOne, ...
>> I also want to express that in one request ideally (point 2).
>> I let the Java framework optimize for me and send as few SQL request  
>> as possible.
>>
>> Basically, there is 2 "filters" to distinguish :
>> * vertical one that can filter several "lines" from the million in  
>> the table : this is the WHERE clause
>> * horizontal one that can bring back only certain column : this is  
>> the SELECT clause
>> both are usefull.
>>
>> Vertical one are well taken into account by all the frameworks I had  
>> to use.
>>
>> Horizontal one had been poorly taken into account by other  
>> frameworks I had to use.
>> I can get back with some instances (vertical filter) but with all  
>> attributes (bad horizontal filter).
>> Or I can have both working but the result is an array of hash tables  
>> and I need instances of my business classes.
>> This is really bad since that hash map's keys are not the attribute  
>> (field) name but the position in the SELECT clause !
>> Meta information is just lost in translation and nobody care :-)
>>
>> Some framework are able to handle poorly (better than not handling  
>> at all) horizontal filtering via eager or lazy loading but this only  
>> concern relational attributes excluding @Basic one and also, most of  
>> the time this can't be set dynamicaly and you have to provide as a  
>> developper specific constructor of your business class.
>> All that horizontal filtaring has to be set statically via  
>> annotation or more painfully via XML but not dynamically.
>> At the end, it is a lot of work for the developper for not having  
>> real horizontal filter.
>>
>> As a conclusion, and as far as I know, OpenJPA was the only one able  
>> to give me back some (efficient vertical filter) instances of my  
>> business classes partially valuated depending on my needs (efficient  
>> horizontal filter) both filters can be specified entirely  
>> dynamically if I want but it is also statically via annotation.
>> This had been possible with only one request.
>>
>> Without any reference to an old OO DB, OpenJPA is a precious  
>> gemstone !
>>
>> On Aug 5, 2009, at 15:36 , Pinaki Poddar wrote:
>>
>>>
>>> Hi,
>>>> I can tell OpenJPA rocks, what I did had been tested impossible to  
>>>> do with
>>>> other frameworks.
>>>
>>> Good to know that you found OpenJPA useful.
>>>
>>> Will you please elaborate which aspects/features of OpenJPA are  
>>> distinct
>>> from other frameworks in your view?
>>>
>>>
>>>
>>>
>>>
>>> -----
>>> Pinaki
>>> -- 
>>> View this message in context:
>>> http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3391748.html
>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>>
>>
>>
> 
> 
> 


-----
Pinaki 
-- 
View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3395110.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Why OpenJPA rocks. was: Custom proxy : idea review needed

Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
Any comments on that vision ?
On Aug 5, 2009, at 16:33 , Jean-Baptiste BRIAUD -- Novlog wrote:

> The need is simple : get trees of partially valuated business object  
> instances from the "big graph" of possible linked business classes.
> The fact came from old SQooL (a bad IT joke from old school and old  
> SQL) :
> 1. only get back from DB what you need.
> 2. the other thing is to try to make as few trip to the DB as  
> possible. One request is better than several.
> DB will optimized if the request look like complex.
> In other words, let the DB optimize for you, as much as possible.
>
> So, I'm in Java, I want instances of my business classes but with  
> only attributes I need (rule 1).
> That attributes that had to be taken or left from the DB can be  
> @Basic one or any other relational one like @ManyToOne, @OneToOne, ...
> I also want to express that in one request ideally (point 2).
> I let the Java framework optimize for me and send as few SQL request  
> as possible.
>
> Basically, there is 2 "filters" to distinguish :
> * vertical one that can filter several "lines" from the million in  
> the table : this is the WHERE clause
> * horizontal one that can bring back only certain column : this is  
> the SELECT clause
> both are usefull.
>
> Vertical one are well taken into account by all the frameworks I had  
> to use.
>
> Horizontal one had been poorly taken into account by other  
> frameworks I had to use.
> I can get back with some instances (vertical filter) but with all  
> attributes (bad horizontal filter).
> Or I can have both working but the result is an array of hash tables  
> and I need instances of my business classes.
> This is really bad since that hash map's keys are not the attribute  
> (field) name but the position in the SELECT clause !
> Meta information is just lost in translation and nobody care :-)
>
> Some framework are able to handle poorly (better than not handling  
> at all) horizontal filtering via eager or lazy loading but this only  
> concern relational attributes excluding @Basic one and also, most of  
> the time this can't be set dynamicaly and you have to provide as a  
> developper specific constructor of your business class.
> All that horizontal filtaring has to be set statically via  
> annotation or more painfully via XML but not dynamically.
> At the end, it is a lot of work for the developper for not having  
> real horizontal filter.
>
> As a conclusion, and as far as I know, OpenJPA was the only one able  
> to give me back some (efficient vertical filter) instances of my  
> business classes partially valuated depending on my needs (efficient  
> horizontal filter) both filters can be specified entirely  
> dynamically if I want but it is also statically via annotation.
> This had been possible with only one request.
>
> Without any reference to an old OO DB, OpenJPA is a precious  
> gemstone !
>
> On Aug 5, 2009, at 15:36 , Pinaki Poddar wrote:
>
>>
>> Hi,
>>> I can tell OpenJPA rocks, what I did had been tested impossible to  
>>> do with
>>> other frameworks.
>>
>> Good to know that you found OpenJPA useful.
>>
>> Will you please elaborate which aspects/features of OpenJPA are  
>> distinct
>> from other frameworks in your view?
>>
>>
>>
>>
>>
>> -----
>> Pinaki
>> -- 
>> View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3391748.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>
>


Re: Why OpenJPA rocks. was: Custom proxy : idea review needed

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Jean-Baptiste,

Thanks for your comments regarding the utility of the fetch plan in  
OpenJPA. The concept of a fetch plan with fetch groups is more than  
three years old but is still not widely adopted nor standardized in JPA.

Your description of "horizontal" versus "vertical" filtering is an  
interesting one. I hadn't heard of fetch plans described using this  
terminology before.

Thanks,

Craig

On Aug 5, 2009, at 7:33 AM, Jean-Baptiste BRIAUD -- Novlog wrote:

> The need is simple : get trees of partially valuated business object  
> instances from the "big graph" of possible linked business classes.
> The fact came from old SQooL (a bad IT joke from old school and old  
> SQL) :
> 1. only get back from DB what you need.
> 2. the other thing is to try to make as few trip to the DB as  
> possible. One request is better than several.
> DB will optimized if the request look like complex.
> In other words, let the DB optimize for you, as much as possible.
>
> So, I'm in Java, I want instances of my business classes but with  
> only attributes I need (rule 1).
> That attributes that had to be taken or left from the DB can be  
> @Basic one or any other relational one like @ManyToOne, @OneToOne, ...
> I also want to express that in one request ideally (point 2).
> I let the Java framework optimize for me and send as few SQL request  
> as possible.
>
> Basically, there is 2 "filters" to distinguish :
> * vertical one that can filter several "lines" from the million in  
> the table : this is the WHERE clause
> * horizontal one that can bring back only certain column : this is  
> the SELECT clause
> both are usefull.
>
> Vertical one are well taken into account by all the frameworks I had  
> to use.
>
> Horizontal one had been poorly taken into account by other  
> frameworks I had to use.
> I can get back with some instances (vertical filter) but with all  
> attributes (bad horizontal filter).
> Or I can have both working but the result is an array of hash tables  
> and I need instances of my business classes.
> This is really bad since that hash map's keys are not the attribute  
> (field) name but the position in the SELECT clause !
> Meta information is just lost in translation and nobody care :-)
>
> Some framework are able to handle poorly (better than not handling  
> at all) horizontal filtering via eager or lazy loading but this only  
> concern relational attributes excluding @Basic one and also, most of  
> the time this can't be set dynamicaly and you have to provide as a  
> developper specific constructor of your business class.
> All that horizontal filtaring has to be set statically via  
> annotation or more painfully via XML but not dynamically.
> At the end, it is a lot of work for the developper for not having  
> real horizontal filter.
>
> As a conclusion, and as far as I know, OpenJPA was the only one able  
> to give me back some (efficient vertical filter) instances of my  
> business classes partially valuated depending on my needs (efficient  
> horizontal filter) both filters can be specified entirely  
> dynamically if I want but it is also statically via annotation.
> This had been possible with only one request.
>
> Without any reference to an old OO DB, OpenJPA is a precious  
> gemstone !
>
> On Aug 5, 2009, at 15:36 , Pinaki Poddar wrote:
>
>>
>> Hi,
>>> I can tell OpenJPA rocks, what I did had been tested impossible to  
>>> do with
>>> other frameworks.
>>
>> Good to know that you found OpenJPA useful.
>>
>> Will you please elaborate which aspects/features of OpenJPA are  
>> distinct
>> from other frameworks in your view?
>>
>>
>>
>>
>>
>> -----
>> Pinaki
>> -- 
>> View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3391748.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>

Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Why OpenJPA rocks. was: Custom proxy : idea review needed

Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
The need is simple : get trees of partially valuated business object  
instances from the "big graph" of possible linked business classes.
The fact came from old SQooL (a bad IT joke from old school and old  
SQL) :
1. only get back from DB what you need.
2. the other thing is to try to make as few trip to the DB as  
possible. One request is better than several.
DB will optimized if the request look like complex.
In other words, let the DB optimize for you, as much as possible.

So, I'm in Java, I want instances of my business classes but with only  
attributes I need (rule 1).
That attributes that had to be taken or left from the DB can be @Basic  
one or any other relational one like @ManyToOne, @OneToOne, ...
I also want to express that in one request ideally (point 2).
I let the Java framework optimize for me and send as few SQL request  
as possible.

Basically, there is 2 "filters" to distinguish :
* vertical one that can filter several "lines" from the million in the  
table : this is the WHERE clause
* horizontal one that can bring back only certain column : this is the  
SELECT clause
both are usefull.

Vertical one are well taken into account by all the frameworks I had  
to use.

Horizontal one had been poorly taken into account by other frameworks  
I had to use.
I can get back with some instances (vertical filter) but with all  
attributes (bad horizontal filter).
Or I can have both working but the result is an array of hash tables  
and I need instances of my business classes.
This is really bad since that hash map's keys are not the attribute  
(field) name but the position in the SELECT clause !
Meta information is just lost in translation and nobody care :-)

Some framework are able to handle poorly (better than not handling at  
all) horizontal filtering via eager or lazy loading but this only  
concern relational attributes excluding @Basic one and also, most of  
the time this can't be set dynamicaly and you have to provide as a  
developper specific constructor of your business class.
All that horizontal filtaring has to be set statically via annotation  
or more painfully via XML but not dynamically.
At the end, it is a lot of work for the developper for not having real  
horizontal filter.

As a conclusion, and as far as I know, OpenJPA was the only one able  
to give me back some (efficient vertical filter) instances of my  
business classes partially valuated depending on my needs (efficient  
horizontal filter) both filters can be specified entirely dynamically  
if I want but it is also statically via annotation.
This had been possible with only one request.

Without any reference to an old OO DB, OpenJPA is a precious gemstone !

On Aug 5, 2009, at 15:36 , Pinaki Poddar wrote:

>
> Hi,
>> I can tell OpenJPA rocks, what I did had been tested impossible to  
>> do with
>> other frameworks.
>
> Good to know that you found OpenJPA useful.
>
> Will you please elaborate which aspects/features of OpenJPA are  
> distinct
> from other frameworks in your view?
>
>
>
>
>
> -----
> Pinaki
> -- 
> View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3391748.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Custom proxy : idea review needed

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
> I can tell OpenJPA rocks, what I did had been tested impossible to do with
> other frameworks.

Good to know that you found OpenJPA useful.

Will you please elaborate which aspects/features of OpenJPA are distinct
from other frameworks in your view?





-----
Pinaki 
-- 
View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3391748.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Custom proxy : idea review needed

Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
Hi OpenJPA devs, Kevin,

you can quote me on that now ! I had validated the choice for OpenJPA.
Now, in case of problem, we'll fight rather than try another less  
powerful framework :-)

Again, thanks to all OpenJPA devs for your work !

On Aug 4, 2009, at 19:27 , Kevin Sutter wrote:

> On Tue, Aug 4, 2009 at 11:10 AM, Jean-Baptiste BRIAUD -- Novlog <
> j-b.briaud@novlog.com> wrote:
>
>>
>> I can tell OpenJPA rocks, what I did had been tested impossible to  
>> do with
>> other frameworks.
>
>
> Can we quote you on that?  :-)  Thanks so much for vote of  
> confidence.  Much
> appreciated.
>
> Kevin
>
>
>>
>>
>> Thanks a lot.
>>
>>
[CUT]

Re: Custom proxy : idea review needed

Posted by Kevin Sutter <kw...@gmail.com>.
On Tue, Aug 4, 2009 at 11:10 AM, Jean-Baptiste BRIAUD -- Novlog <
j-b.briaud@novlog.com> wrote:

>
> I can tell OpenJPA rocks, what I did had been tested impossible to do with
> other frameworks.


Can we quote you on that?  :-)  Thanks so much for vote of confidence.  Much
appreciated.

Kevin


>
>
> Thanks a lot.
>
>
> On Aug 4, 2009, at 15:25 , Michael Dick wrote:
>
>  Hi Jean-Baptiste,
>>
>> The stack shows that you're using OpenJPA's automatic enhancement
>> mechanism
>> (subclassing). Have you tried using build time enhancement [1]?
>>
>> [1] http://openjpa.apache.org/entity-enhancement.html
>>
>> -mike
>>
>> On Tue, Aug 4, 2009 at 7:58 AM, Jean-Baptiste BRIAUD -- Novlog <
>> j-b.briaud@novlog.com> wrote:
>>
>>  One more precision : it is not failling if I call getField() but
>>> apparently
>>> only if field is a collection and if I call .size() method.
>>> Could that be a bug somewhere in enhancement or proxy of collection ?
>>>
>>> To illustrate : an exemple where A has a collection of B :
>>>
>>>
>>> // Here, A had been detached and entity manager had been closed
>>> // Note that B had not explicitly detached.
>>>
>>> // The collection of A came from a query "SELECT a FROM A a" but with a
>>> fetch plan to restrict B and other values not to be retreived.
>>>
>>> for(A a : collection of A) {
>>> B bs = a.getB(); // is not null but can't be evaluated in the debugger
>>> due
>>> to a NPE even if the console do not show any stack
>>> if (bs != null) {
>>>      // SO we're going here because bs is not null. Don't know what's
>>> inside as it can't be evaluated in the debugger.
>>>      bs.size(); // NPE is here in the console and also in the debugger.
>>> }
>>> }
>>>
>>> Here is the stack :
>>>
>>>      NullPointerException : The exception has no message in it
>>> java.lang.NullPointerException
>>>      at
>>> org.apache.openjpa.enhance.p$q$A$pcsubclass.pcReplaceField(Unknown
>>> Source)
>>>      at
>>>
>>> org.apache.openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java:3025)
>>>      at
>>>
>>> org.apache.openjpa.kernel.StateManagerImpl.storeStringField(StateManagerImpl.java:2498)
>>>      at
>>>
>>> org.apache.openjpa.kernel.StateManagerImpl.storeString(StateManagerImpl.java:2489)
>>>      at
>>>
>>> org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy.load(StringFieldStrategy.java:155)
>>>      at
>>> org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:813)
>>>      at
>>>
>>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1056)
>>>      at
>>>
>>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1008)
>>>      at
>>>
>>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:678)
>>>      at
>>>
>>> org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
>>>      at
>>> org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
>>>      at
>>>
>>> org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2921)
>>>      at
>>>
>>> org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2999)
>>>      at
>>>
>>> org.apache.openjpa.kernel.StateManagerImpl.fetchObjectField(StateManagerImpl.java:2242)
>>>      at
>>>
>>> org.apache.openjpa.kernel.StateManagerImpl.fetchField(StateManagerImpl.java:778)
>>>      at
>>>
>>> org.apache.openjpa.kernel.StateManagerImpl.fetch(StateManagerImpl.java:740)
>>>      at
>>>
>>> org.apache.openjpa.enhance.RedefinitionHelper$1.invoke(RedefinitionHelper.java:230)
>>>      at $Proxy21.size(Unknown Source)
>>>
>>>
>>>
>>> On Aug 4, 2009, at 14:41 , Jean-Baptiste BRIAUD -- Novlog wrote:
>>>
>>> it is still failling !
>>>
>>>> After detaching and even closing the entity manager, accessing a not
>>>> retreived field using fetch plan cause a NPE in pcReplaceField ...
>>>>
>>>> I'm completly blocked and in the dark ... I even don't see where
>>>> investigating more now ...
>>>>
>>>> Any idea ?
>>>>
>>>>
>>>>
>>>> On Aug 4, 2009, at 11:51 , Jean-Baptiste BRIAUD -- Novlog wrote:
>>>>
>>>>
>>>>  On Aug 4, 2009, at 03:06 , Michael Dick wrote:
>>>>>
>>>>>
>>>>>  Hi,
>>>>>>
>>>>>> Have you tried detaching your entities? When an entity is detached
>>>>>> OpenJPA
>>>>>> won't go to the database to load a field. So we'll return null for
>>>>>> anything
>>>>>> that isn't in your fetch group (exception : if you load the field
>>>>>> prior
>>>>>> to
>>>>>> detaching then it will be available).
>>>>>>
>>>>>>  This is a good point and it had worked, but I'm puzzled : I thought
>>>>> closing the entityManager will detach managed entities ... and
>>>>> apparently it
>>>>> is not the case.
>>>>> If I want to detach entity, I have to detach it explicitly, I didn't
>>>>> spot
>>>>> that.
>>>>>
>>>>>
>>>>>> You can detach by calling EntityManager.clear() or
>>>>>> OpenJPAEntityManager.detach(Object o). Either way it'll be a lot
>>>>>> easier
>>>>>> than
>>>>>> creating your own proxy class.
>>>>>>
>>>>>>  Sure, it is a *lot* more easier :-)
>>>>> I'm using detachAll to detach a full collection at once.
>>>>> I'm not sure about the behavior of clear(), should clear all managed
>>>>> entity ?
>>>>>
>>>>> By the way, this detach behavior will be ammended in version 2.x, I
>>>>> might
>>>>> try this version, but I feel it could be risky ... On the other hand,
>>>>> my
>>>>> project's time frame fit well with this version 2.
>>>>> Any feedback on 2.0 relliability ?
>>>>>
>>>>>
>>>>>  Hope this helps,
>>>>>>
>>>>>>  It solve the problem, big big thanks !
>>>>>
>>>>>  -mike
>>>>>>
>>>>>>
>>>>>> Jean-Baptiste BRIAUD -- Novlog wrote:
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> My question is "is there simpler things to do ?"
>>>>>>> Please, review that idea and don't hesitate to comment ...
>>>>>>>
>>>>>>> Step 1 : I want partial object, not hashtables. It could be a Person
>>>>>>> with only some attributes having values.
>>>>>>> this concern not only @Basic attribute but also any relational
>>>>>>> attributes like @ManyToOne, ...
>>>>>>> => I used fetch plan and it works fine.
>>>>>>>
>>>>>>> Step 2 : I'm using an Apache lib via a third party framework that
>>>>>>> explore all accessors (beanutils).
>>>>>>> Unfortunatly, unretreived attributes came with a proxy.
>>>>>>> As a consequence, all unreitreived attributes are now retreived
>>>>>>> wasting all the benefit of having used fetch plan ...
>>>>>>>
>>>>>>> Step 3 : I first try to get rid of that proxies but without success,
>>>>>>> so I though I could just have my own proxy that could subclass the
>>>>>>> OpenJPA default proxy
>>>>>>> and just ensure in my subclass that when I need no proxy, the default
>>>>>>> behavior is bypassed.
>>>>>>>
>>>>>>> What do you think about that idea ?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>  --
>>>>>> View this message in context:
>>>>>>
>>>>>> http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3381672.html
>>>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>

Re: Custom proxy : idea review needed

Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
Wow ... that was that and I would never ever had the idea to change  
the way classes are enhanced !

So, now the classes are enhanced at build time it all works fine.
I add my voice to the doc, runtime dynamic enhancement are just for  
quick test, anything serious need build time enhancement.

I can tell OpenJPA rocks, what I did had been tested impossible to do  
with other frameworks.

Thanks a lot.

On Aug 4, 2009, at 15:25 , Michael Dick wrote:

> Hi Jean-Baptiste,
>
> The stack shows that you're using OpenJPA's automatic enhancement  
> mechanism
> (subclassing). Have you tried using build time enhancement [1]?
>
> [1] http://openjpa.apache.org/entity-enhancement.html
>
> -mike
>
> On Tue, Aug 4, 2009 at 7:58 AM, Jean-Baptiste BRIAUD -- Novlog <
> j-b.briaud@novlog.com> wrote:
>
>> One more precision : it is not failling if I call getField() but  
>> apparently
>> only if field is a collection and if I call .size() method.
>> Could that be a bug somewhere in enhancement or proxy of collection ?
>>
>> To illustrate : an exemple where A has a collection of B :
>>
>>
>> // Here, A had been detached and entity manager had been closed
>> // Note that B had not explicitly detached.
>>
>> // The collection of A came from a query "SELECT a FROM A a" but  
>> with a
>> fetch plan to restrict B and other values not to be retreived.
>>
>> for(A a : collection of A) {
>> B bs = a.getB(); // is not null but can't be evaluated in the  
>> debugger due
>> to a NPE even if the console do not show any stack
>> if (bs != null) {
>>       // SO we're going here because bs is not null. Don't know  
>> what's
>> inside as it can't be evaluated in the debugger.
>>       bs.size(); // NPE is here in the console and also in the  
>> debugger.
>> }
>> }
>>
>> Here is the stack :
>>
>>       NullPointerException : The exception has no message in it
>> java.lang.NullPointerException
>>       at
>> org.apache.openjpa.enhance.p$q$A$pcsubclass.pcReplaceField(Unknown  
>> Source)
>>       at
>> org 
>> .apache 
>> .openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java: 
>> 3025)
>>       at
>> org 
>> .apache 
>> .openjpa 
>> .kernel.StateManagerImpl.storeStringField(StateManagerImpl.java:2498)
>>       at
>> org 
>> .apache 
>> .openjpa.kernel.StateManagerImpl.storeString(StateManagerImpl.java: 
>> 2489)
>>       at
>> org 
>> .apache 
>> .openjpa 
>> .jdbc.meta.strats.StringFieldStrategy.load(StringFieldStrategy.java: 
>> 155)
>>       at
>> org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:813)
>>       at
>> org 
>> .apache 
>> .openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java: 
>> 1056)
>>       at
>> org 
>> .apache 
>> .openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java: 
>> 1008)
>>       at
>> org 
>> .apache 
>> .openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:678)
>>       at
>> org 
>> .apache 
>> .openjpa 
>> .kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
>>       at
>> org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java: 
>> 78)
>>       at
>> org 
>> .apache 
>> .openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java: 
>> 2921)
>>       at
>> org 
>> .apache 
>> .openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java: 
>> 2999)
>>       at
>> org 
>> .apache 
>> .openjpa 
>> .kernel.StateManagerImpl.fetchObjectField(StateManagerImpl.java:2242)
>>       at
>> org 
>> .apache 
>> .openjpa.kernel.StateManagerImpl.fetchField(StateManagerImpl.java: 
>> 778)
>>       at
>> org 
>> .apache.openjpa.kernel.StateManagerImpl.fetch(StateManagerImpl.java: 
>> 740)
>>       at
>> org.apache.openjpa.enhance.RedefinitionHelper 
>> $1.invoke(RedefinitionHelper.java:230)
>>       at $Proxy21.size(Unknown Source)
>>
>>
>>
>> On Aug 4, 2009, at 14:41 , Jean-Baptiste BRIAUD -- Novlog wrote:
>>
>> it is still failling !
>>> After detaching and even closing the entity manager, accessing a not
>>> retreived field using fetch plan cause a NPE in pcReplaceField ...
>>>
>>> I'm completly blocked and in the dark ... I even don't see where
>>> investigating more now ...
>>>
>>> Any idea ?
>>>
>>>
>>>
>>> On Aug 4, 2009, at 11:51 , Jean-Baptiste BRIAUD -- Novlog wrote:
>>>
>>>
>>>> On Aug 4, 2009, at 03:06 , Michael Dick wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> Have you tried detaching your entities? When an entity is detached
>>>>> OpenJPA
>>>>> won't go to the database to load a field. So we'll return null for
>>>>> anything
>>>>> that isn't in your fetch group (exception : if you load the  
>>>>> field prior
>>>>> to
>>>>> detaching then it will be available).
>>>>>
>>>> This is a good point and it had worked, but I'm puzzled : I thought
>>>> closing the entityManager will detach managed entities ... and  
>>>> apparently it
>>>> is not the case.
>>>> If I want to detach entity, I have to detach it explicitly, I  
>>>> didn't spot
>>>> that.
>>>>
>>>>>
>>>>> You can detach by calling EntityManager.clear() or
>>>>> OpenJPAEntityManager.detach(Object o). Either way it'll be a lot  
>>>>> easier
>>>>> than
>>>>> creating your own proxy class.
>>>>>
>>>> Sure, it is a *lot* more easier :-)
>>>> I'm using detachAll to detach a full collection at once.
>>>> I'm not sure about the behavior of clear(), should clear all  
>>>> managed
>>>> entity ?
>>>>
>>>> By the way, this detach behavior will be ammended in version 2.x,  
>>>> I might
>>>> try this version, but I feel it could be risky ... On the other  
>>>> hand, my
>>>> project's time frame fit well with this version 2.
>>>> Any feedback on 2.0 relliability ?
>>>>
>>>>
>>>>> Hope this helps,
>>>>>
>>>> It solve the problem, big big thanks !
>>>>
>>>>> -mike
>>>>>
>>>>>
>>>>> Jean-Baptiste BRIAUD -- Novlog wrote:
>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> My question is "is there simpler things to do ?"
>>>>>> Please, review that idea and don't hesitate to comment ...
>>>>>>
>>>>>> Step 1 : I want partial object, not hashtables. It could be a  
>>>>>> Person
>>>>>> with only some attributes having values.
>>>>>> this concern not only @Basic attribute but also any relational
>>>>>> attributes like @ManyToOne, ...
>>>>>> => I used fetch plan and it works fine.
>>>>>>
>>>>>> Step 2 : I'm using an Apache lib via a third party framework that
>>>>>> explore all accessors (beanutils).
>>>>>> Unfortunatly, unretreived attributes came with a proxy.
>>>>>> As a consequence, all unreitreived attributes are now retreived
>>>>>> wasting all the benefit of having used fetch plan ...
>>>>>>
>>>>>> Step 3 : I first try to get rid of that proxies but without  
>>>>>> success,
>>>>>> so I though I could just have my own proxy that could subclass  
>>>>>> the
>>>>>> OpenJPA default proxy
>>>>>> and just ensure in my subclass that when I need no proxy, the  
>>>>>> default
>>>>>> behavior is bypassed.
>>>>>>
>>>>>> What do you think about that idea ?
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3381672.html
>>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>


Re: Custom proxy : idea review needed

Posted by Michael Dick <mi...@gmail.com>.
Hi Jean-Baptiste,

The stack shows that you're using OpenJPA's automatic enhancement mechanism
(subclassing). Have you tried using build time enhancement [1]?

[1] http://openjpa.apache.org/entity-enhancement.html

-mike

On Tue, Aug 4, 2009 at 7:58 AM, Jean-Baptiste BRIAUD -- Novlog <
j-b.briaud@novlog.com> wrote:

> One more precision : it is not failling if I call getField() but apparently
> only if field is a collection and if I call .size() method.
> Could that be a bug somewhere in enhancement or proxy of collection ?
>
> To illustrate : an exemple where A has a collection of B :
>
>
> // Here, A had been detached and entity manager had been closed
> // Note that B had not explicitly detached.
>
> // The collection of A came from a query "SELECT a FROM A a" but with a
> fetch plan to restrict B and other values not to be retreived.
>
> for(A a : collection of A) {
>  B bs = a.getB(); // is not null but can't be evaluated in the debugger due
> to a NPE even if the console do not show any stack
>  if (bs != null) {
>        // SO we're going here because bs is not null. Don't know what's
> inside as it can't be evaluated in the debugger.
>        bs.size(); // NPE is here in the console and also in the debugger.
>  }
> }
>
> Here is the stack :
>
>        NullPointerException : The exception has no message in it
> java.lang.NullPointerException
>        at
> org.apache.openjpa.enhance.p$q$A$pcsubclass.pcReplaceField(Unknown Source)
>        at
> org.apache.openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java:3025)
>        at
> org.apache.openjpa.kernel.StateManagerImpl.storeStringField(StateManagerImpl.java:2498)
>        at
> org.apache.openjpa.kernel.StateManagerImpl.storeString(StateManagerImpl.java:2489)
>        at
> org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy.load(StringFieldStrategy.java:155)
>        at
> org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:813)
>        at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1056)
>        at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1008)
>        at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:678)
>        at
> org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
>        at
> org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
>        at
> org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2921)
>        at
> org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2999)
>        at
> org.apache.openjpa.kernel.StateManagerImpl.fetchObjectField(StateManagerImpl.java:2242)
>        at
> org.apache.openjpa.kernel.StateManagerImpl.fetchField(StateManagerImpl.java:778)
>        at
> org.apache.openjpa.kernel.StateManagerImpl.fetch(StateManagerImpl.java:740)
>        at
> org.apache.openjpa.enhance.RedefinitionHelper$1.invoke(RedefinitionHelper.java:230)
>        at $Proxy21.size(Unknown Source)
>
>
>
> On Aug 4, 2009, at 14:41 , Jean-Baptiste BRIAUD -- Novlog wrote:
>
>  it is still failling !
>> After detaching and even closing the entity manager, accessing a not
>> retreived field using fetch plan cause a NPE in pcReplaceField ...
>>
>> I'm completly blocked and in the dark ... I even don't see where
>> investigating more now ...
>>
>> Any idea ?
>>
>>
>>
>> On Aug 4, 2009, at 11:51 , Jean-Baptiste BRIAUD -- Novlog wrote:
>>
>>
>>> On Aug 4, 2009, at 03:06 , Michael Dick wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> Have you tried detaching your entities? When an entity is detached
>>>> OpenJPA
>>>> won't go to the database to load a field. So we'll return null for
>>>> anything
>>>> that isn't in your fetch group (exception : if you load the field prior
>>>> to
>>>> detaching then it will be available).
>>>>
>>> This is a good point and it had worked, but I'm puzzled : I thought
>>> closing the entityManager will detach managed entities ... and apparently it
>>> is not the case.
>>> If I want to detach entity, I have to detach it explicitly, I didn't spot
>>> that.
>>>
>>>>
>>>> You can detach by calling EntityManager.clear() or
>>>> OpenJPAEntityManager.detach(Object o). Either way it'll be a lot easier
>>>> than
>>>> creating your own proxy class.
>>>>
>>> Sure, it is a *lot* more easier :-)
>>> I'm using detachAll to detach a full collection at once.
>>> I'm not sure about the behavior of clear(), should clear all managed
>>> entity ?
>>>
>>> By the way, this detach behavior will be ammended in version 2.x, I might
>>> try this version, but I feel it could be risky ... On the other hand, my
>>> project's time frame fit well with this version 2.
>>> Any feedback on 2.0 relliability ?
>>>
>>>
>>>> Hope this helps,
>>>>
>>> It solve the problem, big big thanks !
>>>
>>>> -mike
>>>>
>>>>
>>>> Jean-Baptiste BRIAUD -- Novlog wrote:
>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> My question is "is there simpler things to do ?"
>>>>> Please, review that idea and don't hesitate to comment ...
>>>>>
>>>>> Step 1 : I want partial object, not hashtables. It could be a Person
>>>>> with only some attributes having values.
>>>>> this concern not only @Basic attribute but also any relational
>>>>> attributes like @ManyToOne, ...
>>>>> => I used fetch plan and it works fine.
>>>>>
>>>>> Step 2 : I'm using an Apache lib via a third party framework that
>>>>> explore all accessors (beanutils).
>>>>> Unfortunatly, unretreived attributes came with a proxy.
>>>>> As a consequence, all unreitreived attributes are now retreived
>>>>> wasting all the benefit of having used fetch plan ...
>>>>>
>>>>> Step 3 : I first try to get rid of that proxies but without success,
>>>>> so I though I could just have my own proxy that could subclass the
>>>>> OpenJPA default proxy
>>>>> and just ensure in my subclass that when I need no proxy, the default
>>>>> behavior is bypassed.
>>>>>
>>>>> What do you think about that idea ?
>>>>>
>>>>>
>>>>>
>>>> --
>>>> View this message in context:
>>>> http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3381672.html
>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>>
>

Re: Custom proxy : idea review needed

Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
One more precision : it is not failling if I call getField() but  
apparently only if field is a collection and if I call .size() method.
Could that be a bug somewhere in enhancement or proxy of collection ?

To illustrate : an exemple where A has a collection of B :


// Here, A had been detached and entity manager had been closed
// Note that B had not explicitly detached.

// The collection of A came from a query "SELECT a FROM A a" but with  
a fetch plan to restrict B and other values not to be retreived.

for(A a : collection of A) {
   B bs = a.getB(); // is not null but can't be evaluated in the  
debugger due to a NPE even if the console do not show any stack
   if (bs != null) {
	// SO we're going here because bs is not null. Don't know what's  
inside as it can't be evaluated in the debugger.
	bs.size(); // NPE is here in the console and also in the debugger.
   }
}

Here is the stack :

	NullPointerException : The exception has no message in it
java.lang.NullPointerException
	at org.apache.openjpa.enhance.p$q$A$pcsubclass.pcReplaceField(Unknown  
Source)
	at  
org 
.apache 
.openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java: 
3025)
	at  
org 
.apache 
.openjpa 
.kernel.StateManagerImpl.storeStringField(StateManagerImpl.java:2498)
	at  
org 
.apache 
.openjpa.kernel.StateManagerImpl.storeString(StateManagerImpl.java:2489)
	at  
org 
.apache 
.openjpa 
.jdbc.meta.strats.StringFieldStrategy.load(StringFieldStrategy.java:155)
	at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java: 
813)
	at  
org 
.apache 
.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1056)
	at  
org 
.apache 
.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1008)
	at  
org 
.apache 
.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:678)
	at  
org 
.apache 
.openjpa 
.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
	at  
org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
	at  
org 
.apache 
.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2921)
	at  
org 
.apache 
.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2999)
	at  
org 
.apache 
.openjpa 
.kernel.StateManagerImpl.fetchObjectField(StateManagerImpl.java:2242)
	at  
org 
.apache 
.openjpa.kernel.StateManagerImpl.fetchField(StateManagerImpl.java:778)
	at  
org.apache.openjpa.kernel.StateManagerImpl.fetch(StateManagerImpl.java: 
740)
	at org.apache.openjpa.enhance.RedefinitionHelper 
$1.invoke(RedefinitionHelper.java:230)
	at $Proxy21.size(Unknown Source)


On Aug 4, 2009, at 14:41 , Jean-Baptiste BRIAUD -- Novlog wrote:

> it is still failling !
> After detaching and even closing the entity manager, accessing a not  
> retreived field using fetch plan cause a NPE in pcReplaceField ...
>
> I'm completly blocked and in the dark ... I even don't see where  
> investigating more now ...
>
> Any idea ?
>
>
>
> On Aug 4, 2009, at 11:51 , Jean-Baptiste BRIAUD -- Novlog wrote:
>
>>
>> On Aug 4, 2009, at 03:06 , Michael Dick wrote:
>>
>>>
>>> Hi,
>>>
>>> Have you tried detaching your entities? When an entity is detached  
>>> OpenJPA
>>> won't go to the database to load a field. So we'll return null for  
>>> anything
>>> that isn't in your fetch group (exception : if you load the field  
>>> prior to
>>> detaching then it will be available).
>> This is a good point and it had worked, but I'm puzzled : I thought  
>> closing the entityManager will detach managed entities ... and  
>> apparently it is not the case.
>> If I want to detach entity, I have to detach it explicitly, I  
>> didn't spot that.
>>>
>>> You can detach by calling EntityManager.clear() or
>>> OpenJPAEntityManager.detach(Object o). Either way it'll be a lot  
>>> easier than
>>> creating your own proxy class.
>> Sure, it is a *lot* more easier :-)
>> I'm using detachAll to detach a full collection at once.
>> I'm not sure about the behavior of clear(), should clear all  
>> managed entity ?
>>
>> By the way, this detach behavior will be ammended in version 2.x, I  
>> might try this version, but I feel it could be risky ... On the  
>> other hand, my project's time frame fit well with this version 2.
>> Any feedback on 2.0 relliability ?
>>
>>>
>>> Hope this helps,
>> It solve the problem, big big thanks !
>>> -mike
>>>
>>>
>>> Jean-Baptiste BRIAUD -- Novlog wrote:
>>>>
>>>> Hi,
>>>>
>>>> My question is "is there simpler things to do ?"
>>>> Please, review that idea and don't hesitate to comment ...
>>>>
>>>> Step 1 : I want partial object, not hashtables. It could be a  
>>>> Person
>>>> with only some attributes having values.
>>>> this concern not only @Basic attribute but also any relational
>>>> attributes like @ManyToOne, ...
>>>> => I used fetch plan and it works fine.
>>>>
>>>> Step 2 : I'm using an Apache lib via a third party framework that
>>>> explore all accessors (beanutils).
>>>> Unfortunatly, unretreived attributes came with a proxy.
>>>> As a consequence, all unreitreived attributes are now retreived
>>>> wasting all the benefit of having used fetch plan ...
>>>>
>>>> Step 3 : I first try to get rid of that proxies but without  
>>>> success,
>>>> so I though I could just have my own proxy that could subclass the
>>>> OpenJPA default proxy
>>>> and just ensure in my subclass that when I need no proxy, the  
>>>> default
>>>> behavior is bypassed.
>>>>
>>>> What do you think about that idea ?
>>>>
>>>>
>>>
>>> -- 
>>> View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3381672.html
>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>>
>>
>>
>
>


Re: Custom proxy : idea review needed

Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
it is still failling !
After detaching and even closing the entity manager, accessing a not  
retreived field using fetch plan cause a NPE in pcReplaceField ...

I'm completly blocked and in the dark ... I even don't see where  
investigating more now ...

Any idea ?



On Aug 4, 2009, at 11:51 , Jean-Baptiste BRIAUD -- Novlog wrote:

>
> On Aug 4, 2009, at 03:06 , Michael Dick wrote:
>
>>
>> Hi,
>>
>> Have you tried detaching your entities? When an entity is detached  
>> OpenJPA
>> won't go to the database to load a field. So we'll return null for  
>> anything
>> that isn't in your fetch group (exception : if you load the field  
>> prior to
>> detaching then it will be available).
> This is a good point and it had worked, but I'm puzzled : I thought  
> closing the entityManager will detach managed entities ... and  
> apparently it is not the case.
> If I want to detach entity, I have to detach it explicitly, I didn't  
> spot that.
>>
>> You can detach by calling EntityManager.clear() or
>> OpenJPAEntityManager.detach(Object o). Either way it'll be a lot  
>> easier than
>> creating your own proxy class.
> Sure, it is a *lot* more easier :-)
> I'm using detachAll to detach a full collection at once.
> I'm not sure about the behavior of clear(), should clear all managed  
> entity ?
>
> By the way, this detach behavior will be ammended in version 2.x, I  
> might try this version, but I feel it could be risky ... On the  
> other hand, my project's time frame fit well with this version 2.
> Any feedback on 2.0 relliability ?
>
>>
>> Hope this helps,
> It solve the problem, big big thanks !
>> -mike
>>
>>
>> Jean-Baptiste BRIAUD -- Novlog wrote:
>>>
>>> Hi,
>>>
>>> My question is "is there simpler things to do ?"
>>> Please, review that idea and don't hesitate to comment ...
>>>
>>> Step 1 : I want partial object, not hashtables. It could be a Person
>>> with only some attributes having values.
>>> this concern not only @Basic attribute but also any relational
>>> attributes like @ManyToOne, ...
>>> => I used fetch plan and it works fine.
>>>
>>> Step 2 : I'm using an Apache lib via a third party framework that
>>> explore all accessors (beanutils).
>>> Unfortunatly, unretreived attributes came with a proxy.
>>> As a consequence, all unreitreived attributes are now retreived
>>> wasting all the benefit of having used fetch plan ...
>>>
>>> Step 3 : I first try to get rid of that proxies but without success,
>>> so I though I could just have my own proxy that could subclass the
>>> OpenJPA default proxy
>>> and just ensure in my subclass that when I need no proxy, the  
>>> default
>>> behavior is bypassed.
>>>
>>> What do you think about that idea ?
>>>
>>>
>>
>> -- 
>> View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3381672.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>
>


Re: Custom proxy : idea review needed

Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
On Aug 4, 2009, at 03:06 , Michael Dick wrote:

>
> Hi,
>
> Have you tried detaching your entities? When an entity is detached  
> OpenJPA
> won't go to the database to load a field. So we'll return null for  
> anything
> that isn't in your fetch group (exception : if you load the field  
> prior to
> detaching then it will be available).
This is a good point and it had worked, but I'm puzzled : I thought  
closing the entityManager will detach managed entities ... and  
apparently it is not the case.
If I want to detach entity, I have to detach it explicitly, I didn't  
spot that.
>
> You can detach by calling EntityManager.clear() or
> OpenJPAEntityManager.detach(Object o). Either way it'll be a lot  
> easier than
> creating your own proxy class.
Sure, it is a *lot* more easier :-)
I'm using detachAll to detach a full collection at once.
I'm not sure about the behavior of clear(), should clear all managed  
entity ?

By the way, this detach behavior will be ammended in version 2.x, I  
might try this version, but I feel it could be risky ... On the other  
hand, my project's time frame fit well with this version 2.
Any feedback on 2.0 relliability ?

>
> Hope this helps,
It solve the problem, big big thanks !
> -mike
>
>
> Jean-Baptiste BRIAUD -- Novlog wrote:
>>
>> Hi,
>>
>> My question is "is there simpler things to do ?"
>> Please, review that idea and don't hesitate to comment ...
>>
>> Step 1 : I want partial object, not hashtables. It could be a Person
>> with only some attributes having values.
>> this concern not only @Basic attribute but also any relational
>> attributes like @ManyToOne, ...
>> => I used fetch plan and it works fine.
>>
>> Step 2 : I'm using an Apache lib via a third party framework that
>> explore all accessors (beanutils).
>> Unfortunatly, unretreived attributes came with a proxy.
>> As a consequence, all unreitreived attributes are now retreived
>> wasting all the benefit of having used fetch plan ...
>>
>> Step 3 : I first try to get rid of that proxies but without success,
>> so I though I could just have my own proxy that could subclass the
>> OpenJPA default proxy
>> and just ensure in my subclass that when I need no proxy, the default
>> behavior is bypassed.
>>
>> What do you think about that idea ?
>>
>>
>
> -- 
> View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3381672.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Custom proxy : idea review needed

Posted by Michael Dick <mi...@gmail.com>.
Hi,

Have you tried detaching your entities? When an entity is detached OpenJPA
won't go to the database to load a field. So we'll return null for anything
that isn't in your fetch group (exception : if you load the field prior to
detaching then it will be available).

You can detach by calling EntityManager.clear() or
OpenJPAEntityManager.detach(Object o). Either way it'll be a lot easier than
creating your own proxy class.  

Hope this helps,
-mike


Jean-Baptiste BRIAUD -- Novlog wrote:
> 
> Hi,
> 
> My question is "is there simpler things to do ?"
> Please, review that idea and don't hesitate to comment ...
> 
> Step 1 : I want partial object, not hashtables. It could be a Person  
> with only some attributes having values.
> this concern not only @Basic attribute but also any relational  
> attributes like @ManyToOne, ...
> => I used fetch plan and it works fine.
> 
> Step 2 : I'm using an Apache lib via a third party framework that  
> explore all accessors (beanutils).
> Unfortunatly, unretreived attributes came with a proxy.
> As a consequence, all unreitreived attributes are now retreived  
> wasting all the benefit of having used fetch plan ...
> 
> Step 3 : I first try to get rid of that proxies but without success,
> so I though I could just have my own proxy that could subclass the  
> OpenJPA default proxy
> and just ensure in my subclass that when I need no proxy, the default  
> behavior is bypassed.
> 
> What do you think about that idea ?
> 
> 

-- 
View this message in context: http://n2.nabble.com/Custom-proxy-%3A-idea-review-needed-tp3376839p3381672.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.