Alexander Lamb (dev | 1 Sep 2007 08:42
Picon

Re: Null pointer in Cayenne 2.0.3 code


> I see Andrus already replied a bit ...
>
> One thing I'd suggest doing when you go back and re-work it is to  
> not do:
>
> Expression q = Expression.fromString("patientPk = '" + pk + "'");
>
> This could cause you problems if your string value ever has single
> quotes in it or other special characters.  It is far better to use
> bindings.  A better pattern for strings (or just in general) would
> look like:
>
> final Expression expression = Expression.fromString("patientPk =  
> $pk");
> Map parameters = new HashMap(1);
> parameters.put("pk", pk);
> SelectQuery query = new SelectQuery(Patient.class,
> expression.expWithParameters(parameters));
> List items = dataContext.performQuery(query);
>
> By creating an expression with substitution parameters, Cayenne will
> quote and escape text correctly for you.  Of course, perhaps you
> already know all of this and it was is just test code you were trying
> to get to work.  :-)

Exactly... in desperation, you end up trying many different things!
>
> /dev/mrg
>
(Continue reading)

Alexander Lamb (dev | 1 Sep 2007 08:51
Picon

Re: Null pointer in Cayenne 2.0.3 code

Well, the app is actually a Tapestry 5 app... so maybe there is an  
issue with serialization. I will check. However, a few lines before,  
I fetched another entity without any trouble.
Now, the DataContext is an attribute of a class I instantiate from a  
Tapestry page. The DataContext is simply created doing a new  
DataContext(). I would understand the problem if my page was being  
serialized and deserialized, but the crash happens during the first  
request (actually, it is a page from which I upload an XML file which  
will be parsed and data inserted in the database, using a freshly  
created DataContext).

But what you are saying is DataContext has a null EntityResolver.  
This could come from deserializing a DataContext.
What else could make the DataContext loose the EntityResolver? Is  
there one EntityResolver per DataContext or per Entity?

Thanks,

Alex

Le 31 août 07 à 17:40, Andrus Adamchik a écrit :

> The line numbers from 2.0 branch should match:
>
>    https://svn.apache.org/repos/asf/cayenne/main/branches/STABLE-2.0/
>
> Looking at the code, it seems to come down to DataContext having a  
> null EntityResolver. A random thought - is there a serialization/ 
> deserialization cycle somewhere in your app, so that the  
> DataContext somehow loses its EntityResolver and can't properly  
(Continue reading)

Andrus Adamchik | 1 Sep 2007 09:03
Favicon

Re: Null pointer in Cayenne 2.0.3 code


On Sep 1, 2007, at 9:51 AM, Alexander Lamb (dev) wrote:

> But what you are saying is DataContext has a null EntityResolver.

Yes, but I guess the first thing to check is whether my assumption  
about this is true in your code [if(context.getEntityResolver() ==  
null) { ... }].

> This could come from deserializing a DataContext.

Potentially, although in most cases it works, but see my last comment  
below - I think another reason is more likely.

> What else could make the DataContext loose the EntityResolver? Is  
> there one EntityResolver per DataContext or per Entity?

There's one shared by all contexts (it belongs to a DataDomain).

> The DataContext is simply created doing a new DataContext().

That is probably the reason. This constructor creates a DataContext  
that is not attached to Cayenne stack (as its JavaDoc comment  
states). I would recommend using a static factory method that  
properly connects the context:

    DataContext context = DataContext.createDataContext();

Or if you instantiate Cayenne Configuration yourself instead of using  
the default singleton, check the source of 'createDataContext' and  
(Continue reading)

Andrus Adamchik | 1 Sep 2007 19:20
Favicon

Re: Pointers for JPA integration tutorial

Ok, I found why relationships didn't work - Cayenne enhancer looked  
at the getters/setters for the persistence fields to do enhancement.  
I will be working on fixing this [1], but you can still play with the  
relationships in the meantime (as long as you declare simple getters/ 
setters). I just uploaded a new version of the tutorial [2]. Will get  
to work on fixing the enhancer now.

Does it mean the JPA provider already reached the elusive Alpha?  
Probably not. The criteria for that is vague, but I still feel like  
we need to fix CAY-858 and do some serious testing first.

[1] https://issues.apache.org/cayenne/browse/CAY-858
[2] http://people.apache.org/~aadamchik/tutorial/

Andrus

P.S. From the tutorial writing experience... Vanilla JPA feels like a  
step back to me as a user, compared to Cayenne API (What? I need to  
set/unset both sides of relationship by hand? I need to manage  
transactions?)

On Aug 28, 2007, at 2:52 PM, Andrus Adamchik wrote:

> Hi Shannon,
>
> let me better investigate the scope in the next couple of days.
>
> Andrus
>
>
(Continue reading)

Alexander Lamb (dev | 2 Sep 2007 11:15
Picon

Re: Null pointer in Cayenne 2.0.3 code

>

Andrus,

It now works (or at least, it goes past the problem I had).
Indeed, entityResolver was null.

Initializing correctly the DataContext made it work. Maybe adding an  
Exception in Cayenne warning of a null entity resolver (and telling  
how to initialize the DataContext) could help?

Well, again, thanks a LOT !!!

On a side note, we now have an application deployed with Cayenne  
2.0.3 since approximately 2 months using Tapestry 4.1

We are currently writing another app using Cayenne 2.0.3 and Tapestry  
5. Depending on schedule, we might move to Cayenne 3 in the near future.

Alexander

>> But what you are saying is DataContext has a null EntityResolver.
>
> Yes, but I guess the first thing to check is whether my assumption  
> about this is true in your code [if(context.getEntityResolver() ==  
> null) { ... }].
>
>> This could come from deserializing a DataContext.
>
> Potentially, although in most cases it works, but see my last  
(Continue reading)

Borut Bolčina | 3 Sep 2007 14:50
Picon
Gravatar

[C3] logging

Did you consider using
http://www.slf4j.org/

-Bot
Andrus Adamchik | 3 Sep 2007 14:58
Favicon

Re: [C3] logging

No please... not another logging framework "upgrade" :-)

http://www.almaer.com/blog/archives/001563.html

Andrus

On Sep 3, 2007, at 3:50 PM, Borut Bolčina wrote:

> Did you consider using
> http://www.slf4j.org/
>
> -Bot

Michael Gentry | 4 Sep 2007 00:01
Picon

Re: [C3] logging

I don't know, Andrus ... it says Hibernate is using it ... :-)

/dev/mrg

On 9/3/07, Andrus Adamchik <andrus <at> objectstyle.org> wrote:
> No please... not another logging framework "upgrade" :-)
>
> http://www.almaer.com/blog/archives/001563.html
>
> Andrus
>
> On Sep 3, 2007, at 3:50 PM, Borut Bolčina wrote:
>
> > Did you consider using
> > http://www.slf4j.org/
> >
> > -Bot
>
>
Clark_Shannon | 4 Sep 2007 15:47

RE: Pointers for JPA integration tutorial

Andrus,

Thanks so much!  I look forward to giving it a try this week.  I do
understand your points about Vanilla JPA, but folks here see JPA as "the
answer".  

Shannon

-----Original Message-----
From: Andrus Adamchik [mailto:andrus <at> objectstyle.org] 
Sent: Saturday, September 01, 2007 11:21 AM
To: user <at> cayenne.apache.org
Subject: Re: Pointers for JPA integration tutorial

Ok, I found why relationships didn't work - Cayenne enhancer looked  
at the getters/setters for the persistence fields to do enhancement.  
I will be working on fixing this [1], but you can still play with the  
relationships in the meantime (as long as you declare simple getters/ 
setters). I just uploaded a new version of the tutorial [2]. Will get  
to work on fixing the enhancer now.

Does it mean the JPA provider already reached the elusive Alpha?  
Probably not. The criteria for that is vague, but I still feel like  
we need to fix CAY-858 and do some serious testing first.

[1] https://issues.apache.org/cayenne/browse/CAY-858
[2] http://people.apache.org/~aadamchik/tutorial/

Andrus

(Continue reading)

Gilberto C Andrade | 6 Sep 2007 17:32
Picon

Postgresql 8.2 and cayenne 2.0.3 - idle connections

Hi all!

After following some tips from here:
http://article.gmane.org/gmane.comp.java.cayenne.user/8360, we finally
put our webapp in production:

server: jboss-4.0.2
server: postgresql 8.2

PesquisaDataDominioNode.driver.xml:

<?xml version="1.0" encoding="utf-8"?>
<driver project-version="2.0" class="org.postgresql.Driver">
     <url value="jdbc:postgresql://hostname:5432/bcoproducao"/>
     <connectionPool min="5" max="10" />
     <login userName="pesquisa_user" password="senha"/>
</driver>

While using the application we see that the connections are superior
than max=10. But this haven't caused any problem.

So, after one second deploy (I think is redeploy) on jboss we see that
those opened idle connections (about 30) stay there without been used
and when the app starts we see new connections(5) which are used.

Did anyone have seen this behavior before?

Thanks for any tip!

Gilberto
(Continue reading)


Gmane