User: dsundstrom
Date: 01/11/02 10:23:13
Modified: src/main/org/jboss/ejb/plugins/cmp/bridge
EntityBridgeInvocationHandler.java
Log:
Changed to throw an IllegalStateException if bean provider tries to change
the value of a pk member field after the bean has been created, or if the
bean provider tries to set a cmr-field before the bean has been created.
Revision Changes Path
1.7 +12 -1
jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
Index: EntityBridgeInvocationHandler.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- EntityBridgeInvocationHandler.java 2001/11/01 21:28:22 1.6
+++ EntityBridgeInvocationHandler.java 2001/11/02 18:23:13 1.7
@@ -33,7 +33,7 @@
* One per cmp entity bean instance, including beans in pool.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class EntityBridgeInvocationHandler implements InvocationHandler {
protected EntityContainer container;
@@ -90,6 +90,11 @@
throw new EJBException("Field is read-only: " +
cmpField.getFieldName());
}
+ if(cmpField.isPrimaryKeyMember() && entityBridge.isCreated(ctx)) {
+ throw new IllegalStateException("A field that is a member " +
+ "of the primary key can only be set in ejbCreate");
+ }
+
cmpField.setInstanceValue(ctx, args[0]);
return null;
}
@@ -105,6 +110,12 @@
if(methodName.startsWith("get")) {
return cmrField.getValue(ctx);
} else if(methodName.startsWith("set")) {
+ if(!entityBridge.isCreated(ctx)) {
+ throw new IllegalStateException("A CMR field cannot be set " +
+ "in ejbCreate; this should be done in the ejbPostCreate " +
+ "method instead.");
+ }
+
cmrField.setValue(ctx, args[0]);
return null;
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development