- try {
- java.lang.reflect.Field fd = this.getClass().getDeclaredField("_id");
- if (String.class.isAssignableFrom(fd.getType())) {
- this.setRegisterable(true);
+ // look for the id field in all castor classes (should be an NCName string)
+
+ Class thisclass=this.getClass();
+ setRegisterable(false);
+ while (!thisclass.equals(Vobject.class)) {
+ try {
+ java.lang.reflect.Field fd = thisclass.getDeclaredField("_id");
+ if (String.class.isAssignableFrom(fd.getType())) {
+ this.setRegisterable(true);
+ break;
+ }
+ } catch (SecurityException e) {
+ log.error("Unexpected Security Exception whilst finding id fields to set!",e);
+ } catch (NoSuchFieldException e) {
+ thisclass=thisclass.getSuperclass();