[jboss-user] [Beginners Corner] - Basic CMR Question

ianfmc do-not-reply at jboss.com
Fri Sep 1 19:42:50 EDT 2006

Hi Everyone:

I'm fairly new to J2EE, so this may be a very basic question. I apologize in advance.

I have successfully defined an EJB that reads a table in the HSQL, and correctly reports the values from that table.

As an exercise, I added a second table with a 1:1 relationship to the first, which both have a common ID field. In the first table (Player) this is primary-key (PlayerID), and in the second table (Ranking), it is the foreign-key (also PlayerID). The other two fields in the Player Table are: FirstName and LastName. In the Ranking Table, there are two fields: PlayerID and Ranking.

I created a container managed relation (CMR) using the wizard in Jboss-IDE, but when I now try to get all Player records, I get the following Exception

  | java.sql.SQLException: Column not found: RANKING in statement [SELECT playerID, lastName, firstName, ranking FROM PLAYER WHERE (playerID=?) OR (playerID=?) OR (playerID=?)]

I define the method findAllPlayers() using XDoclet as follows

  |  * @ejb.finder
  |  * query = "SELECT OBJECT(b) FROM Player AS b"
  |  * signature = "java.util.Collection findAllPlayers()"

the XDoclet tag in the first Bean (PlayerBean) looks like this:

  | 	 * Getter for CMR Relationship
  | 	 *
  | 	 * @ejb.interface-method   view-type="remote"
  | 	 * @ejb.relation     name = "Player-Ranking"
  | 	 *                         role-name = "Player_Has_A_Ranking"
  | 	 *                         target-ejb = "Ranking"
  | 	 *                         target-role-name = "Ranking"
  | 	 *                         target-multiple = "no"
  | 	 */
  | 	public abstract String getRanking();

Any advice would be greatly appreciated!

Thanks, Ian.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969020#3969020

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969020

More information about the jboss-user mailing list