Re: cayenne-project.yaml

2025-10-01 Thread John Huss
That is a hallucination. On Wed, Oct 1, 2025 at 9:37 PM Ricardo Parada wrote: > > Is it true that Cayenne 5.0-M1 support .yml or .yaml for configuration and > that it’s the preferred format going forward? > > Or is ChatGPT hallucinating again? > > :-) > > Thanks > Ricardo

Re: Primary key generation

2025-09-24 Thread John Huss
Cayenne-Generated (Default) works for this. By default cayenne uses sequences named "PK_", so "PK_CLAIM" in your example. So if you have existing sequences you'd like to use instead you have to override it to use your naming scheme, by adding these classes. import java.sql.Types; import java.util

Re: Transactions

2024-11-13 Thread John Huss
w to get that. > > On Mon, Nov 11, 2024 at 3:55 PM John Huss wrote: > > > On Mon, Nov 11, 2024 at 2:58 PM Christian Gonzalez < > > christian.gonza...@smartscrubs.com> wrote: > > > > > Hi John, I tried making the transaction using the transaction fa

Re: Transactions

2024-11-11 Thread John Huss
tive? If not, the simplest thing to do would be to turn that off. Otherwise I think you need to handle this transaction start and end outside of the Cayenne APIs. > > On Fri, Nov 8, 2024 at 5:38 PM John Huss wrote: > > > I do manual transaction handling like this: > >

Re: Transactions

2024-11-08 Thread John Huss
I do manual transaction handling like this: TransactionFactory txFactory = CayenneRuntime.getThreadInjector().getInstance(TransactionFactory.class); Transaction tx = txFactory.createTransaction(); tx.begin(); try { // do work context.commitChanges(); tx.commit(); } catch (Exceptio

Re: Cayenne web module deprecated

2023-01-31 Thread John Huss
The web module provides a very small amount of functionality that is pretty easy to copy into your own application. I'd suggest looking at the code of CayenneFilter

Re: Which to pick: Cayenne 4.2 vs. 5.0?

2022-11-21 Thread John Huss
The main feature of 5.0 at this point is the removal of deprecated features (like the ROP platform), so either one is a good choice I'd say. But I'd go with 4.2. On Mon, Nov 21, 2022 at 3:44 PM Hugi Thordarson wrote: > Hi guys! > I'm about to be rid of a legacy DB that's been keeping my most imp

Re: How do I install and use Apache Cayenne?

2022-07-26 Thread John Huss
Start here and then please check back when you have more questions: https://cayenne.apache.org/docs/4.1/getting-started-guide/ On Tue, Jul 26, 2022 at 9:52 AM Turritopsis Dohrnii Teo En Ming < tdtemc...@gmail.com> wrote: > Subject: How do I install and use Apache Cayenne? > > Good day from Singa

Re: Apache cayenne 4.0.2 bug

2022-03-23 Thread John Huss
What version of Java are you using? There wasn't support for JDK 17 yet in that version, so that could be the problem. On Wed, Mar 23, 2022 at 12:25 PM Mustafa Said Tozluoğlu wrote: > Hello, > > I just bought new macbook pro M1 chip. And I have to install apache > cayenne 4.0.2 version becase my

Re: DI container has no binding for key

2022-03-23 Thread John Huss
You have to bind the DI injector to the thread (and unbind it later): CayenneRuntime.*bindThreadInjector*(cayenneRuntime.getInjector()); If you are using servlets, then CayenneFilter will do this for you. Otherwise you can bind it at the start of a request and unbind it at the end. On Wed, Mar 2

Re: Dealing with a commit exception....

2021-06-24 Thread John Huss
t; application and pick up where the process ended. If I had an in memory > >> cache of the hash values, on restart I'd have to read all the previously > >> transferred records and inflate the cache. Another process that > really > >> is > >> going to be

Re: Dealing with a commit exception....

2021-06-23 Thread John Huss
I think it would be better to figure out the "problem" objects before committing by querying the DB and the object context. On Wed, Jun 23, 2021 at 9:47 AM Tony Giaccone wrote: > I have a list of 10 new objects that I've inserted into the objectcontex > and am about to do a commit changes on the

Re: About relationship refresh.

2021-05-09 Thread John Huss
If you want related objects to be refreshed you have to use prefetches to explicitly refresh them. InvalidateObjects doesn't refresh related objects in the object graph, only the objects you explicitly pass to it. On Sun, May 9, 2021 at 1:14 PM yazmin georgina quintal wrote: > Hi, We are using

Re: Heisenbug-ish NullPointerExceptions in DataContext.flushToParent()

2021-05-07 Thread John Huss
limited in size, so it may have purged that entry if you have a busy server. You could try increasing the size of the snapshot cache: org.apache.cayenne.configuration.Constants.SNAPSHOT_CACHE_SIZE_PROPERTY > > - hugi > > > > > On 7 May 2021, at 12:53, John Huss wrote: > >

Re: Heisenbug-ish NullPointerExceptions in DataContext.flushToParent()

2021-05-07 Thread John Huss
} > } > > …the NPE gets thrown by the first line in the for-loop (…snapshot.get( > objAttribute.getDbAttributeName() )). > > So it seems either 'snapshot' or 'objAttribute' is null, probably the > snapshot, right? Any ideas why that might be? &g

Re: Heisenbug-ish NullPointerExceptions in DataContext.flushToParent()

2021-05-07 Thread John Huss
Or if you have older logs, you can look back farther to find one without the cause omitted. On Fri, May 7, 2021 at 7:52 AM John Huss wrote: > It will omit the trace if it has happened a very large number of times. If > you restart the server it will start printing it again when it h

Re: Heisenbug-ish NullPointerExceptions in DataContext.flushToParent()

2021-05-07 Thread John Huss
erException. > > > > On 7 May 2021, at 12:24, John Huss wrote: > > > > The first line of the stack after the Caused By line would tell you the > > line with the problem, wouldn't it? What was that line? > > > > On Fri, May 7, 2021 at 7:16 AM Hugi Tho

Re: Heisenbug-ish NullPointerExceptions in DataContext.flushToParent()

2021-05-07 Thread John Huss
The first line of the stack after the Caused By line would tell you the line with the problem, wouldn't it? What was that line? On Fri, May 7, 2021 at 7:16 AM Hugi Thordarson wrote: > Hi all, > > occasionally my users encounter errors when committing changes to the DB. > The relevant part of the

Re: Configuring multiple DataNodes

2021-04-23 Thread John Huss
erties: > > > > > > > https://cayenne.apache.org/docs/4.1/cayenne-guide/#appendix-a-configuration-properties > > < > > > https://cayenne.apache.org/docs/4.1/cayenne-guide/#appendix-a-configuration-properties > > > > > > > > > > &g

Re: Configuring multiple DataNodes

2021-04-23 Thread John Huss
When you create your ServerRuntime you need to supply a custom DI module to pass the DB connection parameters, something like this: *import* org.apache.cayenne.configuration.Constants; *import* org.apache.cayenne.di.Binder; *import* org.apache.cayenne.di.MapBuilder; *import* org.apache.cayenne.

Re: PK Generation and FrontBase

2021-04-15 Thread John Huss
I don't think FrontBase is very commonly used. I would recommend submitting a minimal example of the problem and someone should be able to fix the issue then. On Thu, Apr 15, 2021 at 3:44 PM Jérémy DE ROYER wrote: > Hello, > > I switched my model from FrontBase to PostgreSQL and it works great.

Re: Executing saved SQL

2021-04-09 Thread John Huss
ppedSelect says it can return a SQLTemplate, which is what this is. But > it seems to need a mapped object which I don't have in this case. > > > > Tony > > On Fri, Apr 9, 2021 at 12:21 PM John Huss wrote: > > > Perhaps this? > > > > Selecting individual

Re: Executing saved SQL

2021-04-09 Thread John Huss
Perhaps this? Selecting individual columns: https://cayenne.apache.org/docs/4.1/cayenne-guide/#selecting-individual-columns On Fri, Apr 9, 2021 at 11:03 AM Tony Giaccone wrote: > So I have a query that does a complicated select, and returns a list > containing a single clob for each row. > > Wh

Re: Managing data from two databases.

2021-04-08 Thread John Huss
Yep, it’s that easy. Just assign each DataMap to the correct DataNode. On Thu, Apr 8, 2021 at 5:50 PM Tony Giaccone wrote: > So I have a model, it has two datanodes and two datamaps. Data map/node > one, represents an oracledb, datamap/node two represents a postgres DB. I > want to read from Or

Re: use Date values in ExpressionFactory.exp

2021-01-02 Thread John Huss
I think the string value would be $0 or $1. Or you can use .params with a map to do by name and use $date or whatever you want to name it. On Sat, Jan 2, 2021 at 8:18 AM Andrea Biasillo wrote: > Yes, there is, but how will be the syntax? > > > > On 2021/01/02 14:07:55, J

Re: use Date values in ExpressionFactory.exp

2021-01-02 Thread John Huss
Isn’t there a version of .exp that takes args? You can pass a date object directly there without worrying about formatting. On Sat, Jan 2, 2021 at 7:49 AM Andrea Biasillo wrote: > Hi Mike! > > > > I have tried with: > > > > Expression expDate = ExpressionFactory.exp("modifiedDate> > TO_DATE('200

Re: ObjectSelect to select uncommitted objects

2020-11-16 Thread John Huss
There isn't anything built-in. I use this method in my own DataContext subclass to do it. Use at your own risk, etc. *public* List selectIncludingPendingChanges(ObjectSelect query) { Set newAndModified = *new* HashSet<>(newObjects()); newAndModified.addAll(modifiedObjects()); Set inMemoryResul

Re: Bug in DataRowsUtils

2020-11-11 Thread John Huss
I also dislike this behavior, but I think it is intentional. As I workaround I lowercase all the DbAttribute names in my DataMap at startup and make sure all my MappedSelects use lowercase names. On Wed, Nov 11, 2020 at 3:38 AM Mark Stobbe wrote: > Hi all, > > > > I was using MappedSelect to qu

Re: about mysql support

2020-11-11 Thread John Huss
Yes, all common DBs that have a JDBC driver are supported. On Wed, Nov 11, 2020 at 3:11 AM 郑岩 wrote: > Hello , I want to know if the Cayenne4 can support mysql8.0 Database? > > > > > >

Re: Query timeout in QueryMetadata

2020-11-10 Thread John Huss
The answer might vary depending on your specific use case. One way to do it would be to: 1) start an explicit transaction, 2) run a query to set the timeout SQLExec.*query*("set statement_timeout = 6").execute(context ); 3) do your work 4) run a query to reset or unset the timeout

Re: Spinning up Cayenne in a unit test.

2020-10-29 Thread John Huss
;> And now on commit changes I get this: > > >> > > >> > > >> Caused by: java.lang.NullPointerException > > >> at > > >> > > > org.apache.cayenne.access.DataDomainInsertBucket.createPermIds(DataDomainInsertBucket.java:103) > > >> at >

Re: Spinning up Cayenne in a unit test.

2020-10-28 Thread John Huss
You could add a node at runtime: DataNode node = *new* DataNode("node"); ... // configure node runtime.getDataDomain().addNode(node); runtime.getDataDomain().setDefaultNode(node); On Wed, Oct 28, 2020 at 2:52 PM Tony Giaccone wrote: > So I have a project which is running in Bootique, but the

Re: MariaDB column with auto increment

2020-10-28 Thread John Huss
I'd turn on SQL logging and check that it is refetching the row via SQL. Also query the DB to verify the value is set there. log4j.logger.org.apache.cayenne.log.JdbcEventLogger = INFO On Wed, Oct 28, 2020 at 2:35 AM Markus Reich wrote: > Hi, > > I'm using Cayenne 4.1. > I have an an object A wi

Re: Expression to compare a property against another property

2020-09-10 Thread John Huss
The generated Property instances in the model classes support this out of the box, but maybe you are using an older version of Cayenne? On Thu, Sep 10, 2020 at 4:00 PM Faizel Dakri wrote: > Is there a facility in Cayenne to create an expression that would compare > a property of one object again

Re: Cayenne 4.2—Modifying SQL generation to always use COALESCE when updating a certain column

2020-09-08 Thread John Huss
Since you are already at the DB level (outside of cayenne) making this change, I would just use a BEFORE UPDATE row-level trigger in Postgres. You can change the value there. Something like this would work: CREATE OR REPLACE FUNCTION company_default() RETURNS trigger AS $$ BEGIN

Re: Cayenne 4.2/Postgres - difference in generated SQL based on nesting in expressions

2020-08-18 Thread John Huss
ave a bad > time. > > What I don't get is why that "=" is generated instead of and "AND". If > there's an "AND" the index gets used, regardless of the order of the > expressions. > > - hugi > > > > > > On 18 Aug 2020, at 18:10

Re: Cayenne 4.2/Postgres - difference in generated SQL based on nesting in expressions

2020-08-18 Thread John Huss
I would tend to think the postgres query planner is smart enough to handle the differences in the placement of parentheses if that is the only difference. But in any case, try adding "explain analyze" to the beginning of the query and then compare the query plans between the fast version and the sl

Re: SpringBoot and Cayenne

2020-08-10 Thread John Huss
Unless you have special needs, yes, there should only be one. On Mon, Aug 10, 2020 at 1:51 PM Tony Giaccone wrote: > So I'm using the example that was posted here a while ago, and I've > modified it to read from a springboot yml file. I noticed that when the > application spins up, each time a n

Re: 4.1 final release

2020-07-13 Thread John Huss
I'm happy with 4.1 going out! On Mon, Jul 13, 2020 at 8:29 AM Hugi Thordarson wrote: > I think at least my hundreds of daily users (that will soon have enjoyed 3 > virtually problem free years in production with 4.1) approve :). > > Although then I'll have to start migrating to 4.2… Can't get ca

Re: Types.OTHER

2020-06-15 Thread John Huss
Yeah, sounds good! Thanks! On Mon, Jun 15, 2020 at 7:22 AM Malcolm Edgar wrote: > That sounds like a great approach to me. > > regards Malcolm > > On Mon, Jun 15, 2020 at 9:49 PM Andrus Adamchik > wrote: > > > > > > > > On Jun 9, 2020, at 5:54 PM,

Re: 4.2 official release date

2020-06-10 Thread John Huss
For what it is worth, I often run pre-release versions in production. I am not running 4.2.M1 yet, but have tested it a lot and have not had any problems. On Wed, Jun 10, 2020 at 2:28 PM Andrea Biasillo wrote: > Hi Andrus! > > Thanks for the response, so it will be not too soon. We really need t

Re: Types.OTHER

2020-06-10 Thread John Huss
nce hit taken from deserializing the value from the DB into an object every time, and I appreciate the simplicity of just getting the object I want (rather than a JSON string) without any other ceremony. But I definitely understand the desire to avoid that deserialization in cases where it appears

Re: Types.OTHER

2020-06-09 Thread John Huss
; > > Collection nodes = > runtime.getDataDomain().getDataNodes(); > > for(DataNode node : nodes) { > > > node.getAdapter().getExtendedTypes().registerType(jsonbType); > > } > > } > > Unless you have a custom DbAdapter as discussed above, an

Re: Building Master Branch

2020-05-26 Thread John Huss
What command are you running to build? I would just start with "mvn clean install" For JSONB support I use this class (basically). But in addition you will probably want an immutable (or optionally immutable) version of Map because changes to the Map attribute itself won't be detected by Cayenne u

Re: From 3.1.2 to 4.0.2

2020-05-07 Thread John Huss
Not at a computer at the moment - try MappedSelect. On Thu, May 7, 2020 at 11:51 AM Sébastien Pérès-Labourdette < sebastien.peres-labourde...@omerin.com> wrote: > Hi. > > In 4.0.2, what happened to getEntityResolver().lookupQuery(queryName) ? > > How to fetch my queries from my datamap xml in 4.0

Re: Can I access metadata (InfoExtension) from my velocity templates

2020-05-05 Thread John Huss
enerationAction > class. > > Thanks again for the pointers. > > F > > > > On May 4, 2020, at 9:56 AM, John Huss wrote: > > > > Unfortunately I'm not a maven user, so I can't really help here. But > > hopefully someone else could chime in. >

Re: MySQL JSON Support

2020-05-05 Thread John Huss
I have been using the Postgres JSONB type as an entity attribute (mapped as jdbc type OTHER) for some time, both with Lists and Maps. You can define an ExtendedType subclass to read the value as a string and parse into a map/list using Jackson's ObjectMapper. On Mon, May 4, 2020 at 11:23 PM Malcol

Re: Can I access metadata (InfoExtension) from my velocity templates

2020-05-04 Thread John Huss
h > in effect while the cgen goal is running. How does one go about altering > the class path for a maven plugin? Or does the plugin pickup the project > dependencies? (Apologies if this is a basic question, I’m not yet a Maven > expert). > > Thanks again for your help, > > F &g

Re: Can I access metadata (InfoExtension) from my velocity templates

2020-04-29 Thread John Huss
I haven't used the metadata / comments yet, so I can't help with that specifically. For the using a custom tool with cgen you need to define a "tools.properties" file in your class path (I would just put it at the root) with contents like this: tools.toolbox = application tools.application.*myU

Re: Template path strip out home directory,

2020-01-20 Thread John Huss
I can't directly answer your question as I don't use modeler directly for class generation, but use a build task instead. I recommend using a build task because you get consistency and you don't have to re-select the templates over and over. I use *ant* for this, but it can be done with maven too:

Re: New "Property" classes requiring Persistent

2019-11-14 Thread John Huss
For a very quick reply, I would recommend using the Java 8 streams API .filter, etc instead of Property for doing things with POJOs. This should perform better and be more debuggable, and be only slightly more verbose. On Thu, Nov 14, 2019 at 4:50 PM Lon Varscsak wrote: > Hey all, > > I use Prop

Re: Help with understanding caching possibly.

2019-10-29 Thread John Huss
Queries will always read from the database unless you explicitly indicate you want a cached result. Prefetches are necessary to ensure related objects are also refreshed by the query, otherwise they may be stale. On Tue, Oct 29, 2019 at 8:05 PM Andrew Willerding wrote: > I'm not sure what this m

Re: 4.1 config file path migration question

2019-10-11 Thread John Huss
You'll have to subclass ResourceLocator and implement it: /** * Finds a collection of matching resources for a given name. The name components must * be separated by forward slashes. */ Collection findResources(String name); For example, The name portion could just be

MappedSelect/SQLTemplate #chain and #chunk directives

2019-10-02 Thread John Huss
Looking at the docs for MappedSelect/SQLTemplate I'm not clear on how to supply the parameters for the #chain and #chunk directives from the java side. How should I structure this data and pass it to the SQLTemplate query? SQL: #chain('O

Re: entity Qualifiers and enums

2019-10-01 Thread John Huss
Some more info would probably help us to understand what you're doing. Is this a java enum? Or just a group of java constants? How are you storing it in the DB? With the string value of the enum constants? Or with the ordinal value or int constant value? I believe the answers are: 1) Yes, you ha

Re: 4.2 modeler change

2019-10-01 Thread John Huss
The way to handle testing for the UI is to write the app in an MVP style, sort of like this: https://stackoverflow.com/questions/11367250/concrete-code-example-of-mvp The gist is to define an interface contract for the view so that you can replace the actual Swing UI View with a mock while testing

Re: Sending data across the wire.

2019-09-19 Thread John Huss
And if this needs to be flexible, I would probably write a small library > that allows a user to define a subset of model to serialize, and then > applies that "submodel" to DataObjects directly (this is the Agrest.io > approach on a smaller scale). But as with any generic solution,

Re: Sending data across the wire.

2019-09-17 Thread John Huss
Here's a link to a default template that you could copy some things from: https://github.com/apache/cayenne/blob/master/cayenne-cgen/src/main/resources/templates/v1_2/singleclass.vm On Tue, Sep 17, 2019 at 4:29 PM John Huss wrote: > It's a small effort to create a custom entit

Re: Sending data across the wire.

2019-09-17 Thread John Huss
It's a small effort to create a custom entity template to generate any kind of entity class you want, for instance for a DTO. You can copy a lot of stuff right out of the regular templates if you want. Then you can use maven or ant to easily regenerate those classes the same way CayenneModeler doe

Re: fetching from cache without sql transaction

2019-09-17 Thread John Huss
LOCAL_CACHE will only return cached data for queries using the *same* objectContext, which is usually the same HTTP request). If you have different objectContexts (requests) then you have to use SHARED_CACHE instead. Then you have to figure out when to invalidate/expire the cached data. On Tue, Se

Re: Cayenne And SpringBoot

2019-08-13 Thread John Huss
You don't want to construct multiple ServerRuntimes, especially not one per context. You just need one runtime and you can create many contexts from it. On Tue, Aug 13, 2019 at 1:09 PM Emerson Castañeda wrote: > I got this working using this approach: > > *dependencies:* > > //for persistency >

Re: Cayenne And SpringBoot

2019-08-13 Thread John Huss
Cayenne is pretty generic as far as integrations go - it should work well and easily with any framework. Just create your ServerRuntime and define a way to retrieve it (using ServletContext.setAttribute is typical). Then you'll want to bind the runtime to each request that comes in, which is all th

Re: ServerRuntime.builder().addConfig

2019-07-18 Thread John Huss
connection > properties depending on whether it's a production system, a dev system, > running tests, etc. > > Yes, that was my original strategy, but then John Huss commented: > > "You should only have one project file. You can change the DB connection > properties using a

Re: ServerRuntime.builder().addConfig

2019-07-17 Thread John Huss
gradle and jenkins > capabilities. Just relying on “classpath” is causing problems right now, > and it does not look reliable (based on the complaints by cayenne runtime). > > Joe > > > > > On Jul 17, 2019, at 10:54 AM, John Huss wrote: > > > > The typical app

Re: ServerRuntime.builder().addConfig

2019-07-17 Thread John Huss
The typical approach is to put the project file in the root of the classpath. What are you trying to override for testing? If it's the database connection properties there are better ways to do that. On Wed, Jul 17, 2019 at 9:25 AM Joe Baldwin wrote: > Goal: > My goal is to provide an unambiguo

Re: Testing & Map

2019-07-06 Thread John Huss
https://stackoverflow.com/questions/18948418/set-database-path-in-cayenne On Sat, Jul 6, 2019 at 8:36 PM Joe Baldwin wrote: > I am trying to genericize the map.xml for multiple instances with multiple > dbnames (looking for a “use ” analogue for cayenne config files - > or a better idea if you h

Re: Deprecate SelectQuery in 4.2

2019-07-01 Thread John Huss
On Mon, Jul 1, 2019 at 2:24 PM Joe Baldwin wrote: > Arseni, > > What is the ObjectSelect analog to > > RefreshQuery > Not sure what equivalent for this one is. > and > setCacheStrategy > ObjectSelect has .cacheStrategy(QueryCacheStrategy strategy, String cacheGroup) > > Than

Re: Deprecate SelectQuery in 4.2

2019-07-01 Thread John Huss
On Mon, Jul 1, 2019 at 11:29 AM Joe Baldwin wrote: > Arseni, > > Disclaimer: > I *just* (this week) upgraded from 4.0.M2 to 4.0.1. I migrated to using > the newer syntax - ex: > > table1.property1.asc() > > > SelectQuery is planned to be deprecated in 4.2. > > My project makes extensive

Re: Deleting a bunch of interrelated objects

2019-05-29 Thread John Huss
If the column name is the same in all the tables it would be pretty easy to loop over all your entities and execute the same delete statement (via raw SQLExec). Put all the the entities with that column in a Set and loop over them, removing one when it succeeds until the set is empty. On Wed, May

Re: Further on modeler problems and a Question..

2019-05-20 Thread John Huss
Just by querying the table at startup you can load it into the Object cache (if your shared cache is enabled, which it is by default). However if you exceed the size of the shared cache it will eventually evict those objects and re-fetch them one at a time as needed (which is bad). On Mon, May 20,

Re: Property class and Serialization

2019-05-14 Thread John Huss
Does this help? https://stackoverflow.com/questions/910374/why-does-java-have-transient-fields On Tue, May 14, 2019 at 5:20 PM Lon Varscsak wrote: > Any reason we can't have Property be Serializable? I have situations where > I will keep references to properties in a web page (like for dynami

Re: Migrate Horizontal Inheritance (EOF) to Cayenne

2019-04-13 Thread John Huss
On Sat, Apr 13, 2019 at 9:26 AM Jérémy DE ROYER wrote: > Hello, > > I’m trying to migrate (eo)models using horizontal inheritance (over > multiple frameworks) but without any success : it’s not possible to > generate the Java classes using Cayenne Modeler. > > I did a test with only one entity (a

Re: Checking a value on a DataObject and modifying it before commit if required

2019-04-04 Thread John Huss
There can be issues if you modify other objects inside lifecycle callbacks (a callback won't be called on that object). I would recommend doing the mods in validateForSave instead. On Thu, Apr 4, 2019 at 6:44 AM Hugi Thordarson wrote: > Yes, this would have been a good idea :). Unfortunately the

Re: Timeout long running selects

2019-03-23 Thread John Huss
Set the statement timeout using the SQL syntax or connection string property provided by your database. https://stackoverflow.com/questions/24092463/psql-set-default-statement-timeout-as-a-user-in-postgres#24093305 On Sat, Mar 23, 2019 at 1:15 PM Mark Stobbe wrote: > Hi all, > > Does anyone hav

Re: Increasing memory leads to OOM error

2018-12-04 Thread John Huss
I would try creating a new ObjectContext every so often, not just invalidating the objects. On Tue, Dec 4, 2018 at 2:58 PM Tony Giaccone wrote: > We're processing a request and generating about 130,000 new objects. Once > these objects are created and saved we'll never need to access them again

Re: Get a TransactionFactory without a server runtime

2018-11-16 Thread John Huss
Usually you would access the injector bound to the thread. I think the API is CayenneRuntime.bindThreadInjector. On Fri, Nov 16, 2018 at 6:34 AM Hugi Thordarson wrote: > Hi all. > I have a library containing some utility code. Most of the utility methods > only accept an ObjectContext as an argum

Re: Iterate thought all queries, apply template, get raw SQL

2018-11-13 Thread John Huss
On Tue, Nov 13, 2018 at 11:34 AM Alexander Petrossian (PAF) < alexander.petross...@gmail.com> wrote: > вт, 13 нояб. 2018 г. в 20:02, Giaccone, Tony >: > > > This is going to be a pretty big task, because of the number of tables no > > matter what you do. Is the problem that there are no foreign k

Re: Iterate thought all queries, apply template, get raw SQL

2018-11-13 Thread John Huss
I'm not really sure what you want. The DB should have foreign keys to define the related tables. Similarly, the Cayenne .map.xml file should have relationships defined between tables to indicate their relationships (via foreign keys). If you have unit tests, running those with SQL logging enable

Re: Controlling object insert order

2018-11-01 Thread John Huss
Without having more details my general recommendation would be to handle the details up front before you get to the Cayenne level. Put things in order in memory and then create your Cayenne Objects and commit them one at a time. On Thu, Nov 1, 2018 at 9:35 AM Hugi Thordarson wrote: > Hi all. > I

Re: Commit Exception

2018-09-28 Thread John Huss
; > Now maybe in the larger scheme of things, it doesn't make sense to identify > which item in the set of items being committed caused the problem. It's > clear it makes sense in my use case, but in the general use case, maybe > not.. > > > Tony > > On Thu,

Re: Commit Exception

2018-09-27 Thread John Huss
ject so that the > commit can be made again. > > On Thu, Sep 27, 2018 at 3:52 PM John Huss wrote: > > > I'd just wrap the whole thing in a database transaction. Then commit your > > ObjectContexts as often as you want to, but the real DB commit won't >

Re: Commit Exception

2018-09-27 Thread John Huss
I'd just wrap the whole thing in a database transaction. Then commit your ObjectContexts as often as you want to, but the real DB commit won't happen until the end. TransactionManager transactionManager = CayenneRuntime.*getThreadInjector* ().getInstance(TransactionManager.*class*); transactionMa

Re: DataObject changes - before commit

2018-09-12 Thread John Huss
Or I suppose you could create fields for each of the original values in the same way that the current values are stored. On Wed, Sep 12, 2018 at 4:32 PM John Huss wrote: > Cayenne stores the original values, but they are in DbEntity > representation rather than ObjEntity representation

Re: DataObject changes - before commit

2018-09-12 Thread John Huss
Cayenne stores the original values, but they are in DbEntity representation rather than ObjEntity representation which makes comparing the two difficult. Without writing a lot of code to convert and compare your best bet would be to use a more efficient data structure without any extra unneeded spa

Re: Problem with Callback not getting called in parent/child setup

2018-08-07 Thread John Huss
Are you taking about parent/child ObjectContexts? I see you're calling commitChangesToParent not commitChanges. Does it work when you call commitChanges instead? Here's the code I have for the callbacks: callbackRegistry = runtime.getDataDomain().getEntityResolver().getCallbackRegistry(); callba

Re: SelectById vs SQLSelect cache behavior

2018-08-01 Thread John Huss
If you want fresh data you shouldn't use .localCache() or you should pass a cache strategy to refresh the cache. You can also force objects to be refreshed on the next access or query by using ObjectContext.invalidateObjects. On Tue, Jul 31, 2018 at 6:35 PM kw...@tybera.com wrote: > I have a si

Re: Redacting db user name and password from XML

2018-07-18 Thread John Huss
On Wed, Jul 18, 2018 at 1:26 PM Meeks, Andrew wrote: > I feel as though a recent bit of code is closely related to the topic in > this old thread. The Cayenne xml element supports a > password with a path external to the application. The observed environment > properties appear to only includ

Re: Accessing a sequence number in java

2018-05-23 Thread John Huss
long myId = ((Number)SQLSelect.dataRowQuery("select nextval('mytable_seq' as id").selectOne(ec).get("id")).longValue(); On Wed, May 23, 2018 at 3:52 PM Tony Giaccone wrote: > Imagine I have a field in a persistent object, the field is not the primary > key, and I want it to be unique. So the o

Re: Cayenne firing faults when it shouldn’t be (or at least I don’t think it should be)

2018-05-12 Thread John Huss
Yes On Sat, May 12, 2018 at 7:12 AM Lon Varscsak wrote: > I have a situation where I fetched a large amount of objects (50k) and > prefetched a bunch of relationships…this all worked as expected (although I > didn’t realize that this set of data was that large at the time)…but what > caught my e

Re: Cayenne context inside weapplication

2018-04-15 Thread John Huss
On Sun, Apr 15, 2018 at 12:47 PM JK wrote: > Hello, > > I have a bit of confusion around how Cayenne contex works inside web > application. > I dont really need to have session scoped context- however, there is a > specific need to have isolated scopes . > > 1) What is the best way to manage Caye

Re: Staged saves pattern ?

2018-04-01 Thread John Huss
e parent. We also can’t fire relationships, > because those relationships will go to the database instead of the parent > context. > >>>>> > >>>>> Ken > >>>>> > >>>>>> On Mar 28, 2018, at 7:11 PM, Hugi Thordarson >

Re: Staged saves pattern ?

2018-03-28 Thread John Huss
Well, you could just save once at the end. Why do you need to save multiple times during the processing? Validation exceptions and Optimistic Locking errors could be handled in the save with some custom logic and a retry. Or if this isn't a super long process you can use a database transaction t

Re: About Improved Transaction API on 4.0

2018-03-20 Thread John Huss
have to catch that again > outside the performInTransaction() call, which doesn't feel how it's > supposed to work. > > Maik > > > > > Am 20.03.2018 um 16:40 schrieb John Huss : > > > > performInTransaction just encapsulates a database transaction,

Re: About Improved Transaction API on 4.0

2018-03-20 Thread John Huss
performInTransaction just encapsulates a database transaction, so it has no affect on the object (ORM) level, it only affects what is visible in the database. So the behavior with commitChanges() is the same as it would be outside a performInTransaction block. On Tue, Mar 20, 2018 at 10:25 AM Ju

Re: Object not cached/SELECT on each access

2018-01-10 Thread John Huss
Hard to say. Is the shared cache enabled? Is it sized big enough? Is the app under memory pressure when this is happening, or is it happening all the time? On Wed, Jan 10, 2018 at 6:35 AM Pascal Robert wrote: > Hi, > > I’m trying to find out why it takes between 200 and 500 ms to convert an >

Re: Truncating a table

2017-12-21 Thread John Huss
It's going to depend on which cache you mean. The query cache can be cleared by setting a cache group on the query that fetches the objects and then removing that cache group later. The shared object cache can be cleared by finding the objects you want in context.getGraphManager().registeredNodes

Re: Cayenne on Android?

2017-12-11 Thread John Huss
I tried a few years ago and got a very basic version running. It was challenging since Android wasn't a full implementation of java. For example the java.beans package was missing. I think Android may have improved this situation since then though... depends how old of an android version you're

Re: QueryCache scope

2017-11-09 Thread John Huss
It is connected to the context in the sense that query results that are localCached in one context will not be retrieved from the cache by another context (but instead hit the DB). However, the objects themselves may continue to reside in memory indefinitely until memory pressure causes them to be

Re: Cache Groups

2017-11-08 Thread John Huss
Yes, invalidating the cache group will remove the cached data for all users or query parameters, etc. It's not great. You can make the cache group more specific (like by adding a username or something to it) and that will work, but you'll need to have these cache names configured in your cache pro

Re: Order of insert/update/delete operations

2017-08-01 Thread John Huss
In this case, I'd do your work inside an explicitly started transaction (don't remember the API offhand). 1) Start transaction 2) Perform your deletes (or whatever you need to happen first) 3) Commit the ObjectContext 4) Perform your other work 5) Commit the ObjectContext 6) Finish the transaction

  1   2   3   >