Creating CMR
I'm trying to create CMR with JBoss and MySQL but I cannot make the relations appear in the database. I'd like something to explain from the begining how to create this kind of relations. I'm a beginner and I'm doing a J2EE application that needs some relations in the db.
I'm using JBoss, MySQL and xDoclet.
[326 byte] By [
sirynxa] at [2007-11-27 4:51:49]

# 1
Not an answer, but I was just looking to solve this very problem myself. Same kit: JBoss, Eclipse, XDoclet, MySQL
Best I have come up with is this link:
http://www.daimi.au.dk/~ntj/j2ee/xdoclet.cmp.relationships.php
Haven't tried it yet, as I've given up for a while, but it looks like what we are both after.
Interesting (probably not) I have 2 problems. I cant get AUTO_INCREMENT to work.
Paul
# 3
I tried the page last night and it worked. I made my own project and created the EJB's with his source code individually, then did my own XDoclet and Packaging and deployed it and it worked.
I also just tried to...
1.Download his zip file: http://www.daimi.au.dk/~ntj/download/ntj.examples.src.zip
2. Unzip into my Eclipse workspace
3. Use "Import... Projects into workspace" to import the unzipped project.
4. Enabled XDoclet and Packaging configurations.
5. Edited the XDoclet "jboss" entry and added my MySQL DataSource.
6. Ran XDoclet and Packaging.
7. Deployed the EAR
8. Deployed the JAR
It worked.
00:48:53,737 INFO [EARDeployer] Init J2EE application: file:/opt/jboss-3.2.5/server/default/deploy/ntj.examples.app.ear
00:49:09,764 INFO [EjbModule] Deploying Address
00:49:09,810 INFO [EjbModule] Deploying RoomType
00:49:09,825 INFO [EjbModule] Deploying House
00:49:09,838 INFO [EjbModule] Deploying Person
00:49:09,850 INFO [EjbModule] Deploying Room
00:49:09,864 INFO [EjbModule] Deploying Car
00:49:14,857 INFO [Car] Created table 'Car' successfully.
00:49:14,881 INFO [Room] Created table 'Room' successfully.
00:49:14,905 INFO [House] Created table 'House' successfully.
00:49:14,937 INFO [Address] Created table 'Address' successfully.
00:49:14,991 INFO [Person] Created table 'Person' successfully.
00:49:15,008 INFO [Person] Created table 'users_to_cars' successfully.
00:49:15,029 INFO [RoomType] Created table 'RoomType' successfully.
00:49:15,040 INFO [RoomType] Created table 'rooms_to_roomtypes' successfully.
00:49:15,043 INFO [EJBDeployer] Deployed: file:/opt/jboss-3.2.5/server/default/tmp/deploy/tmp8145ntj.examples.app.ear-contents/ntj.examples.ejb.jar
00:49:15,217 INFO [EARDeployer] Started J2EE application: file:/opt/jboss-3.2.5/server/default/deploy/ntj.examples.app.ear
The MySQL tables are created successfully.
I have not tried to insert records yet though.
In my other project, I had a problem when I inserted records into a table with an auto increment field. I found a solution to the problem on the web and adding:
* @jboss.entity-command
*name="mysql-get-generated-keys"
*class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand"
... the class="" bit. Solved the problem with NULL keys etc.
I'm not sure which versions, or even which apps you are using, but the page in question does indeed work.
Good luck with your attempt :)
Paul