cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Lattermann <>
Subject Controlling Cayennes JDBC connection usage
Date Sun, 08 Oct 2017 09:39:04 GMT

is it possible to control which database connection is used when
committing an ObjectContext?

For example, when using an explicit transaction, the database
connection used in the thread starting the exception must always be the

Now, I have a use case where I want to obtain a PostgresQL advisory
exclusive session lock and do some DDL to create a db schema. Then I
want to write something into that schema using Cayenne, and after that,
release the lock. That's to somewhat atomically initialize a db schema.

For normal schema usage, I want to obtain an advisory shared lock in the
db connection and use that connection with Cayenne.

That mechanism can also be used to manipulate portions of the database
that must be done without concurrent access.

It's how I solved the problem with Hibernate, where a Hibernate session
represents a JDBC Connection. It is bound to the current thread and
used for all Hibernate DB accesses during the session. That worked
quite well.

Would it be possible to do something similar with Cayenne?

View raw message