cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ramiro Aparicio <>
Subject Re: Vertical inheritance with relationships
Date Mon, 08 Oct 2012 11:44:59 GMT
Hi Andrus,

First of all thank you for all the effort and the fast reply time, I 
really appreciate your help with this issue.
Then the bad news after some decompiling to understand how to load 
modules on web containers I was able to configure everything but it 
seemed that still did not want to work, debugging the problem is that my 
relationships are marked as runtime even if they are defined in the 
model, so to avoid that I just removed that condition from your code 
(not sure if that can create some problems in the future) but now I am 
struggling against a commit exception because of the PK.
In our model the session table is a MYSQL autoincrement field so it is 
marked as database generated on Session table, but as sessionWeb and 
sessionClient rely on Session id they have PK strategy as default, but 
on commit I get an error creating the sessionWeb row as id is null.

Here is the sequence of inserts as logged:

[2012-10-08 13:38:05,376] [http-8443-2] INFO 
( --- transaction 
[2012-10-08 13:38:05,392] [http-8443-2] INFO 
( INSERT INTO session_log 
(sessionStart, sessionType) VALUES (?, ?)
[2012-10-08 13:38:05,392] [http-8443-2] INFO 
( [bind: 
1->sessionStart:'2012-10-08 13:38:05.314', 2->sessionType:2]
[2012-10-08 13:38:05,408] [http-8443-2] INFO 
( Generated PK: 
session_log.idSessionLog = 102839
[2012-10-08 13:38:05,408] [http-8443-2] INFO 
( === updated 1 row.
[2012-10-08 13:38:05,408] [http-8443-2] INFO 
( INSERT INTO activity_log 
(Document_idDocument, SessionLog_idSessionLog, action, log_datetime, 
msg_params, successful) VALUES (?, ?, ?, ?, ?, ?)
[2012-10-08 13:38:05,408] [http-8443-2] INFO 
( [bind: 
1->Document_idDocument:NULL, 2->SessionLog_idSessionLog:102839, 
3->action:04, 4->log_datetime:'2012-10-08 13:38:05.314', 
5->msg_params:NULL, 6->successful:NULL]
[2012-10-08 13:38:05,408] [http-8443-2] INFO 
( Generated PK: 
activity_log.idActivityLog = 124301
[2012-10-08 13:38:05,408] [http-8443-2] INFO 
( === updated 1 row.
[2012-10-08 13:38:05,408] [http-8443-2] INFO 
( INSERT INTO session_log_web 
(User_idUser, id, ip, userAgent) VALUES (?, ?, ?, ?)
[2012-10-08 13:38:05,408] [http-8443-2] INFO 
( [batch bind: 
1->User_idUser:NULL, 2->id:NULL, 3->ip:< 7F,00,00,01>, 
4->userAgent:'Computer/Windows 7/Firefox']

I need to check why the idUser is null but that maybe a controller error.
If you are ok with that I can send you the full model so you can check 
everything is configured as it should (I think I double checked 
everything but just in case).

I will try any workaround I am able to imagine and publish any new info.

Ramiro Aparicio

El 05/10/2012 23:12, Andrus Adamchik escribió:
> Oh, and actually I think we can fix it in the interim per
… The "hack" in the example makes me blush :)
> Andrus
> On Oct 6, 2012, at 12:04 AM, Andrus Adamchik <> wrote:
>> Hi Ramiro,
>> Finally I have something specific for you:
>> In the source code attached to this Jira, I am simply blocking "readOnly" status
of all model relationships. The example is a completely self-conatined project. It is built
against 3.2M1-SNAPSHOT (SVN trunk), but it should work with 3.1B1 as well. And for 3.0.x,
you can simply "inline" the fancy DI module code in "cayennehacks"…
>> Take a look at and cayennehacks package. The "hacks" is what it takes now
to make vertical inheritance relationships work.
>>> If I try to creat a entity relationship on User I must set the target to Session
entity and not WebSession, if I set it to WebSession tells me there is no mapping and if I
choose the correct mapping to WebSession then as there is no entity linked to that table it
complains about no target entity.
>> This part worked for me on 3.1B1 Modeler.
>> Andrus
>> On Oct 5, 2012, at 5:28 PM, Ramiro Aparicio <> wrote:
>>> El 19/09/2012 22:12, Andrus Adamchik escribió:
>>>> On Sep 19, 2012, at 11:24 AM, Ramiro Aparicio <>
>>>>> BTW I tried to do everything with 3.0.2 modeller and finally updated
to 3.1.B1 modeller, Will the model created with 3.1.B1 modeller work with 3.0.2 runtime? (I
want to update the runtime but just in case I can not do it).
>>>> No, once you upgrade the Model to 3.1, there's no (automated) way to go back
to 3.0. The project structure is different in 3.1. The biggest change is that the new projects
have at most 1 domain per project. It is probably doable by manually editing XML, but there's
little point in that. After all the only reason to use the new Modeler is if you are planning
to use the new runtime.
>>>> I'll try to find time to get to the rest of your message. I rarely if ever
use vertical inheritance, but I may try out your scenario.
>>>> Andrus
>>> Hi again,
>>> Ok after the big refactoring I am now able to test this and I get this exception
on commit:
>>> "Cannot set the read-only flattened relationship 'toUser' in ObjEntity 'SessionLogWeb'."
>>> or
>>> "Cannot set the read-only flattened relationship 'runtimeRelationship1' in ObjEntity
>>> depending on which side I try to use when setting the relationship.
>>> (SessionLogWeb is WebSession on my previous example and SessionLog is Session)
>>> So even if only one side of the relationship is marked as read only it is not
possible to set the relationship from either side, as this kind of mapping is a bit unexplored
using cayenne I will happily try any different options but I would like to mantain the vertical
inheritance as this is a logging table that will hold millions of records so using a shared
table will waste too much space.
>>> Thanks in advance.
>>> Ramiro Aparicio

View raw message