Robert Zeigler | 17 May 20:39

modeler + db migration NPE

I've been slowing migrating my apps to 3.1M3. I was working on one yesterday and tweaked the data model. When
I went to use the "Migrate" tool, I hit the exception listed below.

FWIW, I'm running the modeler via cayenne-modeler:run (the maven plugin).  I've seen this now with 2
different projects/models. Both are connecting to a MySQL database. Has anybody else seen this?

I'll take a look at tracking it down, but I'm pretty swamped for the next week or so.

Robert

java.lang.NullPointerException
	at org.apache.cayenne.merge.AbstractToDbToken.executeSql(AbstractToDbToken.java:54)
	at org.apache.cayenne.merge.AbstractToDbToken.execute(AbstractToDbToken.java:45)
	at org.apache.cayenne.modeler.dialog.db.MergerOptions.generateSchemaAction(MergerOptions.java:427)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:491)
	at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:785)
	at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:61)
	at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:819)
	at ognl.ASTMethod.getValueBody(ASTMethod.java:75)
	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
	at ognl.SimpleNode.getValue(SimpleNode.java:210)
	at ognl.Ognl.getValue(Ognl.java:333)
	at ognl.Ognl.getValue(Ognl.java:413)
	at ognl.Ognl.getValue(Ognl.java:395)
	at org.apache.cayenne.swing.BindingBase.getValue(BindingBase.java:168)
	at org.apache.cayenne.swing.ActionBinding.fireAction(ActionBinding.java:80)
(Continue reading)

Bryan Lewis | 17 May 14:06
Picon
Gravatar

multiple database querying

We need to fetch objects from a second database.  (That is, query an entity
in a second domain.)  I've tried a couple of quick things -- putting two
domains in one cayenne.xml project -- but I've been unable to make it work,
in Cayenne 3.0.2 anyway.

I found CAY-1318 which says, "Multi-datadomain runtime configurations offer
no advantage over multiple configurations with a single domain each.  So
going to change the project structure to only support a single
DataDomain."  It says it was fixed in 3.1.

So if we upgrade to 3.1 will we have an easier time?  Are there any
examples of querying from multiple configurations?

Thanks,
Bryan Lewis
Daniel Scheibe | 16 May 22:47

External transactions...

Hi all,

i'm just in the process of creating a web application bound to cayenne 
in the backend. I'm using external transactions (XA with multiple 
databases) and basically start/commit/rollback a transaction whenever i 
have something to change inside the databases. While this is working 
fine i'm trying to understand the way cayenne behaves regarding the 
object context lifecycle.

Imagine the following use case:

startTX();

List<Object> objects = querySomeObjectsViaTheObjectContext();

commitTX(); or rollbackTX();

If i understand correctly relationships are not necessary resolved 
directly but lazy when accessed through an object. My question now is 
how does the object context behave when it has to fetch some additional 
objects due to relationships that have to be resolved on access? I mean 
obviously the object context is no longer valid (?) as potentially the 
external transaction manager might have closed it's correspodning 
datasource and returned it back to the connection pool.

However the objects in my list are still available in memory and can be 
used although cannot be modified easily or be committed in the next 
transaction as they of course don't belong to the newly created object 
context.

(Continue reading)

Joe Baldwin | 16 May 19:47
Picon
Favicon

Best Practice for real-time sort capability (follow-up)

This is an follow-up to a question I asked previously.

**** To re-cap
In the context of a web-app (i.e. you don't know who your users are, or what kind of absurd 'give me everything
and let me sort' actions they might take), I need to be able to support real-time sorting of perhaps large
result sets.

So the recommendation was to prefer the DBMS sort over Cayenne in-memory sort (which would fault all of the
result-set dataobjects).  I can sort of understand the rational that it is better to re-submit the query
with a new sort-by request, as this will ultimately be more memory efficient.

Requirements
Also, I have some fairly advanced pre-built search methods that support often-used searches.  It is the
results of these searches that may be sorted several times and in several different ways by the user.

**** Interesting Side-effect
In order to implement the 'let the DBMS do it' pattern, I created a SearchFactory class that stores the
pre-built Cayenne SelectQuery, so that I can resubmit it to Cayenne with a user chosen sort-by
specification.  Here are some questions:

1. I have to store the SelectQuery in a custom session object.  This *seems* like a good idea but since I have
never done this, I was wondering if storing a query might not be memory-efficient. i.e. does this object
hold on to any result sets?

2. This pattern essentially makes some of the very cool Cayenne ORM features useless. i.e. I can no longer
simply request the Vendor's associated product list by doing a Cayenne 'vendor.getProductList()',
since I can't store the query (as I need to do in order to re-submit the query with a new Ordering object).

This is all working, but since I have to make a *lot* of changes in my code, I want to make sure it is the best
solution with Cayenne.
(Continue reading)

Tony Giaccone | 15 May 23:59

model model, who's got the model….


So here's my situation. I'm building a framework, where I'd like to let my development team choose to use
either sql light or postgres on a shared server as the persistent store. 

Using SQLite  lets them do development locally with out having to install Postgress on each workstation and
or be dependent on a central shared postgres server. 

My first thought was to create two different models and then pick one in the web.xml file. I'm sure this would
work, but the model name would have to be different for each model, so as to avoid file name collision. I'm
not really keen on that idea, because the models are the same and vary only in the values in the data node.  And
then I thought I could put them in different folders, which represented the datanode file.

resources/sqlite/myCayenneModel.xml
resources/postgres/myCayenneModel.xml

But it's not clear to me, how that is handled in the web.xml file.  The filter name is the name of the model, no?
How do you manage that if the model is not at the top level of the classpath? 

After thinking about it, it seems to me the best solution is to ask you all. 

Just to be pedantic here's the problem.

I have two different data models which essentially different only in the value of the  data node. 
I want to be able to choose one model at compile time.  
I don't want to have to change any java code to make the choice. I'd prefer to just edit the web.xml file. 

Anyone have a solution? 

Tony Giaccone
(Continue reading)

Ramiro Aparicio | 9 May 19:28
Gravatar

Stat gathering

Hi,

I am trying to figure some way to get the number or queries and time 
elapsed in a DataContext, or something similar, I want to get agregate 
data about DB performance and be able to find where we should try to 
reduce the number of DB queries.
I thought I could use some kind of ServletFilter to get the data and 
post back as headers or something like that, but I don't se anywhere how 
I can get this information, the best I can see is that all that 
information is logged but not agregated, so maybe I could create a 
custom QueryLogger, but I can not see any way to inject a custom 
QueryLogger either so I am lost.
Maybe this is a marginal use case but I think this is a interesting 
feature for everyone using Cayenne in production enviroments to gather 
information without having to parse the logs.

Ramiro Aparicio

Simran Narula | 7 May 05:45
Favicon

How to turn on escaping for named queries

Hi,

I have a bunch of named queries in my application.map.xml...

And cayenne does not seems to be escaping the parameter values when these queries are executed

Is there a way I can SWITCH ON escaping for these named queries in cayenne or is there no way and I will have to
manually escape the parameter values passed to these queries ??

Thanks
Durchholz, Joachim | 3 May 11:54
Picon
Favicon

RE: Standalone app, Threads and Object contexts

> One thing I found that I must create at least one
> ObjectContextChild before the DataContext becomes
> usable otherwise I'm not seeing the connection being
> made to the database in the log files.

Just in case it's not already clear: A DataContext does not need a connection to be usable. It will grab a
connection as soon as it actually needs one, i.e. when the application starts querying away.

Durchholz, Joachim | 2 May 15:45
Picon
Favicon

RE: Standalone app, Threads and Object contexts

> But maybe I'm misunderstanding what "standalone" means.
> Does it mean Swing? Or a daemon with no UI? Or an
> application which needs to be a double clickable
> executable but still serves web pages?

In the sense that I understand the word, the first two would
usually be designed as a standalone (J2SE) app and the latter
one as a container (J2EE) app.

> In all three cases, Tomcat/Jetty/etc could still be
> part of the solution.

Could, but often wouldn't.
Tomcat etc. are built for high concurrency. Which means ultra-short transaction and connections and many
parallel connections. That's the use case for containers and connection pooling.
If high concurrency is not an issue, you could have just a handful of Swing application banging on the same
database, or even just a sole daemon. In these scenarios, you don't need the container for its
high-concurrency guarantees.
Of course that doesn't mean that a container would necessarily be useless in such scenarios. A container
enforces a design that makes retrying transactions easier, a connection pool ensures that that broken
connections will be recreated ASAP. Both services may or may not be useful to a "standalone" (i.e.
non-web-based) application.

Andrew Willerding | 2 May 15:32

Re: Standalone app, Threads and Object contexts

I'm a little confused by this email thread because it started off as 
questions about derby and then morphed into connection pooling. There 
are lots of connection pooling libraries out there such as c3po and 
dbcp. But I'll step out of this conversation since perhaps I'm not 
understanding what is being asked.
>
> Ari
>
>
My mistake.  I accidentally posted a reply instead of creating a new post.

yunus | 2 May 12:29
Picon

Merge operation

Hi,I have a relation Applicant in which all user details are stored.
I want to give user an option of updating his details so i want to know how
to update Applicant relation in cayenne. Its quite similar like MERGE in JPA
where old date has been replaced if any new changes have been made to the
existing one.Now i want to do this in cayenne..
Thanks in advance

--
View this message in context: http://cayenne.195.n3.nabble.com/Merge-operation-tp3954774.html
Sent from the Cayenne - User mailing list archive at Nabble.com.


Gmane