-
1. Re: CMR-Field also CMP-Field
tolborg Jan 16, 2003 12:46 PM (in response to lafr)I second this question.
-
2. Re: CMR-Field also CMP-Field
ravidwivedi Jan 18, 2003 9:10 AM (in response to lafr)Hi Frank Langelage
have you got any solution for the subject mentioned problem , because i am also facing the same problem?
regards
ravi -
-
4. Re: CMR-Field also CMP-Field
svankirk Jan 19, 2003 12:15 PM (in response to lafr)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?
-
5. Re: CMR-Field also CMP-Field
sebastien_petrucci Jan 23, 2003 9:41 AM (in response to lafr)Hi,
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 ?
Sebastien. -
6. Re: CMR-Field also CMP-Field
tommyg Jan 23, 2003 11:34 AM (in response to lafr)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?
-
7. Re: CMR-Field also CMP-Field
averydford Jan 24, 2003 4:10 PM (in response to lafr)hello lafr,
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'.
IMHO -
** 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? -
8. Re: CMR-Field also CMP-Field
icordoba Jan 26, 2003 10:09 AM (in response to lafr)Hi there,
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...
Good luck,
Ignacio -
9. Re: CMR-Field also CMP-Field
lafr Jan 26, 2003 10:49 AM (in response to lafr)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. -
10. Almost fixed in 3.2
totolaricot Jan 27, 2003 6:42 PM (in response to lafr)Ignacio,
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)
context
name
description
Bean2 (PK = context + ID)
context
ID
quantity
I have a one-to-many relationship between both beans (Bean1 has many Bean2).
I declare the cmr fields as follow:
<key-field>
<field-name>context</field-name>
<column-name>context</column-name>
</key-field>
<key-field>
<field-name>name</field-name>
<column-name>Bean1_Name</column-name>
</key-field>
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:
<key-field>
<field-name>context</field-name>
<column-name>context_foo</column-name>
</key-field>
<key-field>
<field-name>name</field-name>
<column-name>Bean1_Name</column-name>
</key-field>
Both columns are added the the Bean2 table.