-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: many-to-one insert problem
PostPosted: Sun Jul 31, 2005 7:32 am 
Newbie

Joined: Sun Nov 21, 2004 5:21 am
Posts: 14
I'm trying to insert records to the DB and fails due to a many-to-one relation:

ERROR BasicPropertyAccessor:115 - IllegalArgumentException in class: com.bevents.infra.common.metadata.MeasureStatTypeData, getter method of property: id
com.bevents.infra.persistence.util.DataInserterException: Save failed; nested exception is:
java.lang.reflect.InvocationTargetException
at com.bevents.infra.persistence.util.DataInserter.insertDataToTables(DataInserter.java:103)
at com.bevents.infra.extutils.console.db.DataInsertTask.insertDataToTables(DataInsertTask.java:161)
at com.bevents.infra.extutils.console.db.DataInsertTask.runTask(DataInsertTask.java:153)
at com.bevents.infra.extutils.console.swing.ProgressedTask$ActualTask.<init>(ProgressedTask.java:90)
at com.bevents.infra.extutils.console.swing.ProgressedTask$1.construct(ProgressedTask.java:38)
at com.bevents.infra.extutils.console.swing.SwingWorker$2.run(SwingWorker.java:104)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.bevents.infra.persistence.util.DataInserter.insertDataToTables(DataInserter.java:101)
... 6 more
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.bevents.infra.common.metadata.MeasureStatTypeData.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:119)
at org.hibernate.tuple.AbstractTuplizer.getIdentifier(AbstractTuplizer.java:103)
at org.hibernate.persister.entity.BasicEntityPersister.getIdentifier(BasicEntityPersister.java:2944)
at org.hibernate.persister.entity.BasicEntityPersister.isTransient(BasicEntityPersister.java:2705)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.engine.ForeignKeys$Nullifier.isNullifiable(ForeignKeys.java:137)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:69)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:47)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:234)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at com.bevents.infra.persistence.server.bo.AbstractBusinessObject.save(AbstractBusinessObject.java:54)
... 10 more
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@1a220e6
at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:105)
... 28 more


[b]Hibernate mapping[/b]

<class name="com.bevents.infra.common.metadata.GeneralMeasureStatData" table="GENERAL_MEASURE_STATS">
<id name="id" column="ID">
<generator class="assigned"/>
</id>
<many-to-one name="measureStatTypeId"
column="MEASURE_STATS_TYPE_ID"
not-null="true"
class="com.bevents.infra.common.metadata.MeasureStatTypeData" />-->
<property name="measureStatTypeId" column="MEASURE_STATS_TYPE_ID" not-null="true"/>
<property name="description" column="DESCRIPTION" length="50"/>
<property name="columnName" column="COLUMN_NAME" length="50"/>
<property name="isPercent" column="IS_PERCENT" not-null="true"/>
<property name="engineName" column="ENGINE_NAME" length="50"/>
</class>

did anyone use it successfully[b][/b]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 7:34 am 
Newbie

Joined: Sun Nov 21, 2004 5:21 am
Posts: 14
sorry, i gave the wrong mapping - (the problem was not solved)

<class name="com.bevents.infra.common.metadata.GeneralMeasureStatData" table="GENERAL_MEASURE_STATS">
<id name="id" column="ID">
<generator class="assigned"/>
</id>
<many-to-one name="measureStatTypeId"-->
column="MEASURE_STATS_TYPE_ID"-->
update="true" insert="true" not-null="true"--> class="com.bevents.infra.common.metadata.MeasureStatTypeData" />
<property name="description" column="DESCRIPTION" length="50"/>
<property name="columnName" column="COLUMN_NAME" length="50"/>
<property name="isPercent" column="IS_PERCENT" not-null="true"/>
<property name="engineName" column="ENGINE_NAME" length="50"/>
</class>


Top
 Profile  
 
 Post subject: Re: many-to-one insert problem
PostPosted: Sun Jul 31, 2005 9:27 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Post the code of your POJOs (GeneralMeasureStatData, MeasureStatTypeData) as well as the code in which you try to insert the records.

Best regards
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 1:09 am 
Newbie

Joined: Sun Nov 21, 2004 5:21 am
Posts: 14
i'm not sending the AbstractDataObject since it is only implementing a reflection toString()...

[code]
/**
* Represents a relations between a measure stat type to a measure attribute
*/
public class MeasureAttributeStatData extends AbstractDataObject {

int id;
int measureAttributeId;
int measureStatTypeId;
String description;
String columnName;
boolean isPercent;
boolean isForInAll;
String engineName;

public MeasureAttributeStatData(){
}

public MeasureAttributeStatData(int id, int measureAttributeId, int measureStatTypeId, String description, String columnName, boolean isPercent, boolean isForInAll, String engineName) {
this.id = id;
this.measureAttributeId = measureAttributeId;
this.measureStatTypeId = measureStatTypeId;
this.description = description;
this.columnName = columnName;
this.isPercent = isPercent;
this.isForInAll = isForInAll;
this.engineName = engineName;
}

public MeasureAttributeStatData(MeasureAttributeStatData data) {
this.id = data.id;
this.measureAttributeId = data.measureAttributeId;
this.measureStatTypeId = data.measureStatTypeId;
this.description = data.description;
this.columnName = data.columnName;
this.isPercent = data.isPercent;
this.isForInAll = data.isForInAll;
this.engineName = data.engineName;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public int getMeasureAttributeId() {
return measureAttributeId;
}

public void setMeasureAttributeId(int measureAttributeId) {
this.measureAttributeId = measureAttributeId;
}

public int getMeasureStatTypeId() {
return measureStatTypeId;
}

public void setMeasureStatTypeId(int measureStatTypeId) {
this.measureStatTypeId = measureStatTypeId;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getColumnName() {
return columnName;
}

public void setColumnName(String columnName) {
this.columnName = columnName;
}

public boolean getIsPercent() {
return isPercent;
}

public void setIsPercent(boolean percent) {
isPercent = percent;
}

public boolean getIsForInAll() {
return isForInAll;
}

public void setIsForInAll(boolean forInAll) {
isForInAll = forInAll;
}

public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof MeasureAttributeStatData)) {
return false;
}

final MeasureAttributeStatData measureAttributeStatData = (MeasureAttributeStatData)o;

if (id != measureAttributeStatData.id) {
return false;
}
if (isPercent != measureAttributeStatData.isPercent) {
return false;
}
if (measureAttributeId != measureAttributeStatData.measureAttributeId) {
return false;
}
if (measureStatTypeId != measureAttributeStatData.measureStatTypeId) {
return false;
}
if (columnName != null ? !columnName.equals(measureAttributeStatData.columnName) : measureAttributeStatData.columnName != null) {
return false;
}
if (description != null ? !description.equals(measureAttributeStatData.description) : measureAttributeStatData.description != null) {
return false;
}

return true;
}

/**
* @return the engine name (as defined in builder.cfg) of this attribute stat
*/
public String getEngineName() {
return engineName;
}

/**
* @param engineName the engine name (as defined in builder.cfg) of this attribute stat
*/
public void setEngineName(String engineName) {
this.engineName = engineName;
}

}
[/code]

[code]/**
* measure statistic which are general for all measure attributes
*/
public class GeneralMeasureStatData extends MeasureAttributeStatData{

public GeneralMeasureStatData() {
}

public GeneralMeasureStatData(int id, int measureStatTypeId, String description, String columnName, boolean isPercent, String engineName) {
super(id, 0, measureStatTypeId, description, columnName, isPercent, false, engineName);
}

public int getMeasureAttributeId() {
return 0;
}

}
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 7:27 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
I don't see a class MeasureStatTypeData in the code you posted. There must be something wrong with its getter of id (see your exception).

Best regards
Sven


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.