Dain,
Thanks for the reply. I'm beginning to see why this is hard to do, and why we let CMP containers do the hard work!
> It works, but it is not a great solution. The problem is you
> effectively end up with two caches of column values (one in the CMP
> field and on the CMR field), which could become a problem later (cache
> synchronization). The real solution is to write another CMPField
> implementation that wraps the CMR field (very easy). Then there is the
> problem of writing classes to handle the new metadata required (major
> pain). I'm working on the new metadata code which uses XSL and xml data
> binding (haven't decided which one yet).
Never considered the cache problem. I think we're safe on that one, because we only use the cmp field in ejbCreate. After that we call the cmr field setter in ejbPostCreate and always use that afterwards.
The CMPField wrapper would be neat.
>
>
>> I was also having a look at the source to see if we could move the
>> record insertion to after the ejbPostCreate. In CMPPersistenceManager,
>> the CreateEntity() method calls store.createEntity(...). Would it be
>> possible to ask the entity for its primary key (This is actually done in
>> the JDBCCreateEntityCommand.execute() method). Use the key to patch up
>> the cache, and then move the call to store.createEntity() to
>> postCreateEntity() method? I'm sure its not so simple, but you never know!
>
>
> It is not that simple. If you fix the insert problem you still have a
> delete problem. The simplest solution is to use deferred foreign keys
> and database cascade delete (which should work today). There is a guy
> who said that he is working on it, but I don't know how far he is (or if
> he is still working on it).
Again in our system, we don't often delete records. Auditing, don't you know! So the cascade deletion stuff shouldn't be a problem. I presume this is only a problem with non-null foreign key fields, and has nothing to do with moving the INSERT to after ejbPostCreate.
Our wish list for CMP reads:
1. Support doing INSERT after ejbPostCreate instead of ejbCreate.
2. Allow non-null foreign key fields.
3. Support foreign key fields being part of whole of primary key. - Work around is to have an extra fk field that is a copy of the primary key field.
The CMPField wrapper would help in 3.
Thanks for listening, and keep up the good work.
Jonathan O'Connor
Ph: +353 1 872 3305
Mob: +353 86 824 9736
Fax: +353 1 873 3612
- [JBoss-user] CMP Bug: Bad SQL for FK field Jonathan . O'Connor
- Re: [JBoss-user] CMP Bug: Bad SQL for FK field Jonathan . O'Connor
- Re: [JBoss-user] CMP Bug: Bad SQL for FK fiel... Dain Sundstrom
