Hi:
I am using weblogic 8.1 and MyEclipse 5.1.1. I am deploying my ear application through MyEclipse 5.1.1 as an ear file.
When I ran the following EJB QL:
SELECT OBJECT(p) FROM Product p.category = ?1
I get the following error:
n relation Category-Product, a cmr-field and a cmp-field on the bean are using the same name. The names of cmr and cmp fields must be unique.
It is basically complaining that I have a field
category
in my ejb-jar.xml and also the same category in the
category
field. The problem is that if I changed the value of the cmr-field, I have to add a get and set in my productLocal.java and when you do that you have to do the same in the ejb-jar.xml.
Here is my ejb-jar.xml:
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
CategoryEJB
com.CategoryHomeLocal
com.CategoryLocal
com.CategoryBean
Container
java.lang.Integer
False
2.x
Category
categoryId
categoryName
picture
pictureWidth
pictureHeight
labelOn
labelOff
button
categoryId
findCategory
SELECT OBJECT(c) FROM Category c
ProductEJB
com.ProductHomeLocal
com.ProductLocal
com.ProductBean
Container
java.lang.Integer
False
2.x
Product
productId
brandName
productDescription
purchasePrice
category
productId
findProduct
com.CategoryLocal
SELECT OBJECT(p) FROM Product p.category = ?1
Category-Product
Category-has-many-Product-numbers
one
CategoryEJB
productNumbers
java.util.Collection
Product-belongs-to-Category
many
ProductEJB
category
Employees
Employees
CategoryEJB
*
CategoryEJB
*
ProductEJB
*
Required
Here is my weblogic-cmp-rdbms-jar.xml:
<!DOCTYPE weblogic-rdbms-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB RDBMS Persistence//EN'
'http://www.bea.com/servers/wls810/dtd/weblogic-rdbms20-persistence-810.dtd'>
CategoryEJB
ShoeStore
category
categoryId
categoryID
categoryName
categoryName
picture
Picture
pictureWidth
PictureWidth
pictureHeight
PictureHeight
labelOn
LabelOn
labelOff
LabelOff
button
Button
SQL_SERVER
ProductEJB
ShoeStore
PRODUCT
productId
productId
brandName
brandName
productDescription
productDescription
purchasePrice
purchasePrice
category
categoryId
<!-- Automatically generate the value of ID in the database on inserts using sequence table -->
SQL_SERVER
Category-Product
Product-belongs-to-Category
categoryId
categoryID
Here is my productLocal.java:
package com;
import javax.ejb.CreateException;
import javax.naming.NamingException;
import java.util.Date;
import java.util.Vector;
import java.util.Collection;
public interface ProductLocal extends javax.ejb.EJBLocalObject
{
public Integer getProductId();
public void setProductId(Integer productId);
public String getBrandName();
public void setBrandName(String brandName);
public String getProductDescription();
public void setProductDescription(String productDescription);
public Double getPurchasePrice();
public void setPurchasePrice(Double purchasePrice);
public CategoryLocal getCategory();
public void setCategory(CategoryLocal category);
}
Here is my ProductBean.java:
package com;
import javax.naming.InitialContext;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;
import javax.naming.NamingException;
import java.util.Date;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;
import java.lang.Integer;
public abstract class ProductBean implements javax.ejb.EntityBean
{
public Integer ejbCreate(Integer id)
{
this.setProductId(id);
return null;
}
public void ejbPostCreate(Integer id)
{
}
//public abstract Integer getCategoryId();
// public abstract void setCategoryId(Integer categoryId);
public abstract CategoryLocal getCategory();
public abstract void setCategory(CategoryLocal category);
public abstract Integer getProductId();
public abstract void setProductId(Integer productId);
public abstract String getBrandName();
public abstract void setBrandName(String brandName);
public abstract String getProductDescription();
public abstract void setProductDescription(String productDescription);
public abstract Double getPurchasePrice();
public abstract void setPurchasePrice(Double purchasePrice);
public void setEntityContext(EntityContext ec)
{
System.out.println("ProductBean setEntityContext");
}
public void unsetEntityContext()
{
System.out.println("ProductBean unsetEntityContext");
}
public void ejbLoad()
{
System.out.println("ProductBean ejbLoad");
}
public void ejbStore()
{
System.out.println("ProductBean ejbStore");
}
public void ejbActivate()
{
System.out.println("ProductBean ejbActivate");
}
public void ejbPassivate()
{
System.out.println("ProductBean ejbPassivate");
}
public void ejbRemove()
{
System.out.println("ProductBean ejbRemove");
}
}
What do I needed to do to fix this problem.
Any hint or help would be greatly appreciated!!!
Yours,
Frustrated