I second this question.
Hi Frank Langelage
have you got any solution for the subject mentioned problem , because i am also facing the same problem?
No ! I'm sorry.
I have also run into this and haven't found a way around it. This is a major problem. How could CMRs be useful when they don't support this very common and necessary database construct? From everything I have been able to determine, the only solution is to roll your own relationships. Is this a limitation of just JBoss or is it a problem with other containers as well?
I'm also having the same problem.
There is also another limitation.
Imagine that Bean1 has a relation to Bean2.
This relation is mandatory. So you set a NON NULL
foreign key in Bean1's table.
This is also a problem becoz you cannot set a relation
in the ejbCreate() method (setBean2(bean1) will throw an exception). You have to initialize your relation in ejbPostCreate() which already TOO LATE (this is after the INSERT query).
Well to resolve this problem you either not set the FK to NOT NULL, or you get rid of the CMR... not very nice.
If a field could be CMR and CMP at the same time, it would solve all those problems...
Any idea ?
I have this problem as well. This problem has been floating around the forums for the past month that I've been watching. Does anybody from the JBoss group have any thoughts or information as to a solution to this problem?
i have a few questions concerning your problem.
1) what is the dependency of the entities?
2) By predefining the PK/FK combination of Bean2 i assume u hope to get an index to assist with queries?
3) What advantage do u hope to gain by having the PK of 'festa' maintained as a direct access CMP when u can navigate the CMR provided.
-- i assume this is an issue of performance.
-- but even so, this the ejbCreate method of 'Festr' should prevent the creation of 'Festr' entities if a valid 'Festa' local reference is not provided. this maintains ur database integrity since the PK for both entities are none null values.
-- adding a unique index to 'Festr' database table could wait 'tuning'.
** it seems as though the problem is more of domain/entity/erd mapping and design. ur wanting to model an entity bean *exactly* as its represented in the database when CMR will provide the PK for 'Festr' or 'BeanA' through CMR navigation and calling the 'getPrimaryKey()'.
** otherwise u could rename the FK field name u defined in 'Festr' to NOT match the one generated by CMP/CMR deployment and add another parameter to the 'create()' method representing the PK of 'Festa'. clugy - but whats ur alternative?
although I haven't been able to find a worakarround for the problem, you cn have a look at
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ I'd get RC1 of JBoss 3.2 and JBoss 3.0.6 from SourceForge and see if the so long waited feature has been included in these last versions of JBoss. If anyone makes it, please post anything here...
The entities are parts of a production order.
festa is the head. It contains the information about the the item to be produced, when, how much, ...
festr contains the list of materials which are neccessary.
febdr contains the papers to printed for the order.
It's an existing schema which cannot be changed.
I want to access the data in this tables via ejb ProductionOrder with getMaterials(), getPapers(), ...
So I wrote a script which generates ejb's from databasemodel with cmr.
My "problem" is, that in case of the cmr-field is part of the primary key, it must also be a cmp field.
In case it is not part of the pk, the cmr-field must not be a cmp-field, because it is added automatically by cmr.
I built JBoss fron CVS (Branch_3_2) this morning. Apparently the problem has been addressed but not fixed: now instead of duplicating the cmr field that is also a PK field, it creates none of the cmr fields.
Bean1 (PK = context + name)
Bean2 (PK = context + ID)
I have a one-to-many relationship between both beans (Bean1 has many Bean2).
I declare the cmr fields as follow:
The context column is not duplicated to the Bean2 table, which is what we want. The problem is that the Bean1_Name column is not added either.
If I change the declaration as follow:
Both columns are added the the Bean2 table.