cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Re: "Can't get primary key from temporary id" :(
Date Wed, 22 Apr 2009 15:25:13 GMT
FWIW, we are planning on filling in our Audit table using triggers on
the tables we care about auditing.  This will also capture changes
made outside of Cayenne.

On Wed, Apr 22, 2009 at 10:53 AM, Joseph Schmidt
<> wrote:
>>> I'd be interested in hearing what others have to say... feasible given
>>> the current cayenne stack?
>> The problem is that the original poster is trying to use Cayenne like he
>> uses pure SQL and
> No, I'm not.
> Like I mentioned in earlier posts, I'm using ObjRelationships and all the
> Cayenne goodies. Just that for some properties that are not needed/fetched
> by the application itself (but are required for various reasons: legal,
> admin, etc.) those values also must be written inside the same transaction
> in there, so that externals tools/applications can access them in the
> required format (e.g. once a week).
> If we take only the Audit part: years ago it was done with stored procedures
> and triggers. Now because the business logic migrated more and more from the
> DB level(to upper more abstract levels), there's not enough info at the low
> trigger level to do it, so the ORM needs to do it  - in this case: Cayenne
> if it's possible.
>> he hasn't demonstrated how he would even achieve what he wants with pure
>> SQL (hint: LAST_INSERT_ID() is the mysql specific way of getting the last
>> id. His other approaches just don't work. But even LAST_INSERT_ID() would
>> probably create race conditions with multiple concurrent users.)
> Of course I demonstrated. The snippet in the parent just works with MySQL
> (with InnoDB of course).
> There's no need for a last_insert_id(), since the PK are "autoincrement".
> Inside the same transaction, the consequent selects will simply pick the
> correct values (generated by autoincrement). This is how MySQL is mostly
> used.
>> There is however a solution to relationships or attributes which need to
>> be added to 75% of the tables in the database: inheritance. In this case
>> vertical inheritance is the appropriate choice. We are just now testing the
>> excellent work Andrus has done in this area and we have all the basic parts
>> of inheritance working in ROP.
> This sounds interesting.
> thanks,
> Joseph.

View raw message