I am receiving the following error
SEVERE: IllegalArgumentException in class: pmco.pojos.Competitor, getter method of property: id
with what I consider to be a fairly simple parent child relationship between two objects, Scenario being the parent and Competitor being the child. Scenario contains a list of Competitors. The link is one to many and for the moment it is satisfactory for it to be uni-directional from the parent to the child. There is a simple foreign key relationship between the two objects, although not explicitly formed as a constraint in the db.
These two objects are in fact in a hierarchy of parent child objects. I am citing these two as representative of my issue although it happens elsewhere (everywhere else) in the object graph.
I am running Hibernate on the server side of an Adobe Flex project and leaving the marshalling of the calls to Hibernate to the Adobe Hibernate adaptor, which has been proven to work elsewhere and I do not think is the source of this issue. I therefore don't have any code calling Hibernate directly, just the mapping files. The whole thing is running inside a JBoss server instance (any hints on how to attach an Eclipse debugger to my jar code running insde JBoss also gratefully received).
I have read a large number of posts about this error as it seems to be a common mistake that beginners make using Hibernate and I myself am a beginner. There have also been quite a few replies to the issue but none of them shows a really satisfactory conclusion and none seem to relate precisely to my issue as my object structure and relationship seems to be simpler in form. There seems to be a suggestion that either my getter should return a class instance or I have the mapping wrong
I would greatly appreciate help as this is the last remaining issue preventing me from fully adopting the otherwise excellent Hibernate in my project. I'm certain this is my error and am seeking guidance.
Hibernate version:3.2.1ga
Code:
My HSQLDB DDL
Code:
CREATE MEMORY TABLE SCENARIO(
SCENARIO_ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
USER_SCENARIO_ID INTEGER,
PLANPOINT_ID INTEGER,
TITLE VARCHAR(255),
SEQUENCE INTEGER,
POTENTIAL DOUBLE)
CREATE MEMORY TABLE COMPETITOR(
COMPETITOR_ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
SCENARIO_ID INTEGER,
USER_SCENARIO_ID INTEGER,
PLANPOINT_ID INTEGER,
NAME VARCHAR(255),
X DOUBLE,
Y DOUBLE,
RADIUS DOUBLE,
ACTUAL DOUBLE,
PROPOSITIONS DOUBLE,
ORDER_SIZE DOUBLE,
CONVERSION_RATE DOUBLE)
My Mapping doc
Code:
<class name="Scenario" table="SCENARIO">
<id name="id" column="SCENARIO_ID" type="int">
<generator class="increment" />
</id>
<property name="planpoint_id" column="PLANPOINT_ID" type="int" />
<property name="user_scenario_id" column="USER_SCENARIO_ID" type="int" />
<property name="name" column="TITLE" type="string" length="255" />
<property name="sequence" column="SEQUENCE" type="int" />
<property name="potential" column="POTENTIAL" type="double" />
<bag name="competitors" cascade="all">
<key column="SCENARIO_ID"/>
<one-to-many class="Competitor"/>
</bag>
</class>
<class name="Competitor" table="COMPETITOR">
<id name="id" column="COMPETITOR_ID" type="int">
<generator class="increment" />
</id>
<property name="planpoint_id" column="PLANPOINT_ID" type="int" />
<property name="user_scenario_id" column="USER_SCENARIO_ID" type="int" />
<property name="scenario_id" column="SCENARIO_ID" type="int" />
<property name="name" column="NAME" type="string" length="255" />
<property name="x" column="X" type="double" />
<property name="y" column="Y" type="double" />
<property name="radius" column="RADIUS" type="double" />
<property name="actual" column="ACTUAL" type="double" />
<property name="propositions" column="PROPOSITIONS" type="double" />
<property name="order_size" column="ORDER_SIZE" type="double" />
<property name="conversion_rate" column="CONVERSION_RATE" type="double" />
</class>
My Parent Scenario pojo
Code:
public class Scenario
{
private List competitors;
private String name;
private int id;
private int planpoint_id;
private int user_scenario_id;
private int sequence;
private double potential;
public List getCompetitors() {
return competitors;
}
public void setCompetitors(List competitors) {
this.competitors = competitors;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getSequence() {
return sequence;
}
public void setSequence(int sequence) {
this.sequence = sequence;
}
public int getUser_scenario_id() {
return user_scenario_id;
}
public void setUser_scenario_id(int userscenario_id) {
this.user_scenario_id = userscenario_id;
}
public int getPlanpoint_id() {
return planpoint_id;
}
public void setPlanpoint_id(int planpoint_id) {
this.planpoint_id = planpoint_id;
}
public double getPotential() {
return potential;
}
public void setPotential(double potential) {
this.potential = potential;
}
}
My child competitor pojo
Code:
public class Competitor
{
private String name;
private double actual;
private double x;
private double y;
private double radius;
private int id;
private int user_scenario_id;
private int scenario_id;
private int planpoint_id;
private double propositions;
private double order_size;
private double conversion_rate;
public double getActual() {
return actual;
}
public void setActual(double actual) {
this.actual = actual;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPlanpoint_id() {
return planpoint_id;
}
public void setPlanpoint_id(int planpoint_id) {
this.planpoint_id = planpoint_id;
}
public double getConversion_rate() {
return conversion_rate;
}
public void setConversion_rate(double conversion_rate) {
this.conversion_rate = conversion_rate;
}
public double getOrder_size() {
return order_size;
}
public void setOrder_size(double order_size) {
this.order_size = order_size;
}
public double getPropositions() {
return propositions;
}
public void setPropositions(double propositions) {
this.propositions = propositions;
}
public int getScenario_id() {
return scenario_id;
}
public void setScenario_id(int scenario_id) {
this.scenario_id = scenario_id;
}
public int getUser_scenario_id() {
return user_scenario_id;
}
public void setUser_scenario_id(int user_scenario_id) {
this.user_scenario_id = user_scenario_id;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}
Full stack trace of any exception that occurs:
Here is a portion of the stack trace generated by JBoss including a section which is generated by Flex, the full one is a meg...
2007-01-19 12:23:43,889 ERROR [STDERR] 19-Jan-2007 12:23:43 org.hibernate.property.BasicPropertyAccessor$BasicGetter get
SEVERE: IllegalArgumentException in class: pmco.pojos.Competitor, getter method of property: id
2007-01-19 12:23:43,889 INFO [STDOUT] [Flex] Serializing AMF/RTMP response
Version: 3
(Command method=_error (0) trxId=4)
(Typed Object #0 'flex.messaging.messages.ErrorMessage')
rootCause = (Typed Object #1 'org.hibernate.PropertyAccessException')
throwables = (Array #2)
[0] = (Ref #1)
[1] = (Typed Object #3 'java.lang.IllegalArgumentException')
localizedMessage = "java.lang.ClassCastException@493b65"
message = "java.lang.ClassCastException@493b65"
cause = null
persistentClass = (Typed Object #4 'java.lang.Class')
localizedMessage = "IllegalArgumentException occurred calling getter of pmco.pojos.Competitor.id"
propertyName = "id"
message = "IllegalArgumentException occurred calling getter of pmco.pojos.Competitor.id"
cause = (Ref #3)
throwableCount = 2
messages = (Array #5)
[0] = "IllegalArgumentException occurred calling"
[1] = "java.lang.ClassCastException@493b65"
destination = "planpoint.hibernate"
headers = (Object #6)
correlationId = "B4532402-B4F3-877D-B36D-3B629F888A9E"
faultString = "Could not invoke sync method on data adapter for destination 'planpoint.hibernate' due to the following error: class org.hibernate.PropertyAccessException:IllegalArgumentException occurred calling getter of pmco.pojos.Competitor.id."
messageId = "A0FBCA02-011D-5083-2228-1A55D61E33FD"
faultCode = "Server.Processing"
timeToLive = 0.0
extendedData = null
faultDetail = null
clientId = null
timestamp = 1.169227423889E12
body = null
Name and version of the database you are using:HSQLDB
Thanks in advance for your help.