This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 72681

Summary: IAE thrown from BeanProp
Product: ide Reporter: Martin Adamek <madamek>
Component: Schema2BeansAssignee: schema2beans-issues@ide <schema2beans-issues>
Status: RESOLVED FIXED    
Severity: blocker CC: pjiricka
Priority: P1    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Thrown exception
Schema with problematic attributes
Very primitive patch for inspiration. It handles this particular problem, but it's not systematic enough.

Description Martin Adamek 2006-02-15 09:27:27 UTC
When following attribute is defined in element in xsd:
<xsd:complexType name="entity">
  <xsd:attribute name="class" type="xsd:string" use="required"/>
...
and attrProp is set to true in s2b Ant task, following field with appropriate
getter.setter is created in generated Entity class:
static public final String CLASS2 = "Class2";
There is "Class2" name used, because getClass() is already existing method and
getClass2() is generated instead. Problem is in Entity's parent element -
EntityMappings, where folowing code is generated:
this.createAttribute(EMBEDDABLE, "class", "Class", ...)
but it should be:
this.createAttribute(EMBEDDABLE, "class", "Class2", ...).
"java.lang.IllegalArgumentException: Unknown attribute Class2 for property
Entity" is thrown for this call:
entityMappings.addEntity(entity);
Comment 1 Martin Adamek 2006-02-15 09:28:14 UTC
Created attachment 28887 [details]
Thrown exception
Comment 2 Martin Adamek 2006-02-15 09:29:28 UTC
Created attachment 28888 [details]
Schema with problematic attributes
Comment 3 Martin Adamek 2006-02-15 09:32:28 UTC
Created attachment 28889 [details]
Very primitive patch for inspiration. It handles this particular problem, but it's not systematic enough.
Comment 4 _ cliffwd 2006-02-21 19:40:14 UTC
The determination of whether or not something gets renamed (a number gets
appended) is made in BeanBuilder.java.  For attributes, it's in addAttrProp
around line 481.  It has access to the AttrProp and probably should change the
name in the AttrProp after determining that the property should get renamed.
Comment 5 _ cliffwd 2006-03-02 21:02:15 UTC
Fixed.

Checking in BeanBuilder.java;
/cvs/schema2beans/dev/src/org/netbeans/modules/schema2beansdev/BeanBuilder.java,v
 <--  BeanBuilder.java
new revision: 1.42.24.1; previous revision: 1.42
done