-->
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.  [ 2 posts ] 
Author Message
 Post subject: many-to-many causing PropertyNotFoundException
PostPosted: Mon Mar 06, 2006 6:20 am 
Newbie

Joined: Mon Mar 06, 2006 3:33 am
Posts: 2
Hibernate version:3.0.5
Name and version of the database you are using:MySQL 5.0.18

Hai all,
I develop application using spring 1.2.7 , jdk 1.5, tomcat 5.5.15, and Hibernate 3.0.5.
When deploying classes that have many-to-many relationship on tomcat, I keep getting error:
org.hibernate.PropertyNotFoundException: Could not find a getter for organizations in class model.ChartOfAccount,
although the getter and setter are obviously exist.
But this error is not appear on the test case using org.springframework.test.AbstractTransactionalData SourceSpringContextTests.
Could someone kindly help me.

Belows are the error stack, classes and hibernate mapping.
Thanks in advance for your help.

<====Error Stack ===>
006-03-06 14:55:31,634 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/siriusAccounting-data.xml]: Initialization of bean failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for organizations in class model.ChartOfAccount
org.hibernate.PropertyNotFoundException: Could not find a getter for organizations in class model.ChartOfAccount
at org.hibernate.property.BasicPropertyAccessor.creat eGetter(BasicPropertyAccessor.java:213)
at org.hibernate.property.BasicPropertyAccessor.getGe tter(BasicPropertyAccessor.java:207)
at org.hibernate.mapping.Property.getGetter(Property. java:240)
at org.hibernate.tuple.PojoTuplizer.buildPropertyGett er(PojoTuplizer.java:237)
at org.hibernate.tuple.AbstractTuplizer.<init>(Abstra ctTuplizer.java:73)
at org.hibernate.tuple.PojoTuplizer.<init>(PojoTupliz er.java:54)
at org.hibernate.tuple.TuplizerLookup.create(Tuplizer Lookup.java:47)
at ...



<===== Chart Of Account class ===>

package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class ChartOfAccount implements Serializable{


private static final long serialVersionUID = 7601506566284602484L;
private Integer id;
private String coaID;
private String name;
private String description;
private Set glAccounts = new HashSet();
private Set organizations;




public String toString() {
return "id"+id+",coaID:"+coaID+",name:"+name;
}

public String getCoaID() {
return coaID;
}


public void setCoaID(String coaID) {
this.coaID = coaID;
}


public String getDescription() {
return description;
}


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


public Integer getId() {
return id;
}

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

public String getName() {
return name;
}


public void setName(String name) {
this.name = name;
}

public Set getGlAccounts() {
return glAccounts;
}


public void setGlAccounts(Set glAccounts) {
this.glAccounts = glAccounts;
}

public void addGlAccount(GLAccount glAccount){
glAccount.setCoa(this);
glAccounts.add(glAccount);
}



public Set getOrganizations() {
if(this.organizations == null){
this.organizations=new HashSet();
}
return this.organizations;
}

public void setOrganizations(Set organizations) {
this.organizations = organizations;
}

public void addOrganization(Organization organization){
organization.getChartOfAccounts().add(this);
organizations.add(organization);
}



}



<==== Chart of Account Mapping ===>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping

>

<class
name="model.ChartOfAccount"
table="chart_of_account"
>

<id
name="id"
column="id"
type="integer"
>

<generator
class="native"
>

</generator>

</id>

<property
name="coaID"
type="string"
column="coa_id"
length="50"
>

</property>

<property
name="description"
type="string"
column="description"
length="300"
>

</property>

<property
name="name"
type="string"
column="name"
length="50"
>

</property>

<set
name="glAccounts"
table="glaccount"
inverse="true"
cascade="all-delete-orphan"
order-by="account_number asc"
>

<key
column="fk_coa"
>

</key>

<one-to-many
class="model.GLAccount"
/>

</set>

<set
name="organizations"
table="coa_organization"
lazy="true"
cascade="save-update"
>

<key
column="coa_id"
>

</key>

<many-to-many
class="model.Organization"
column="organization_id"
>

</many-to-many>

</set>

</class>

</hibernate-mapping>





<===== Organization class ===>
package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Organization implements Serializable{

private static final long serialVersionUID = 651560668855945216L;
private Integer id;
private String name;
private Set chartOfAccounts = new HashSet();
private String organizationCode;





public String toString() {
return "id: "+id+"; name: "+name+"; Organization code: "+organizationCode;
}




public Integer getId() {
return id;
}



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




public Set getChartOfAccounts() {
return chartOfAccounts;
}




public void setChartOfAccounts(Set chartOfAccounts) {
this.chartOfAccounts = chartOfAccounts;
}

public void addChartOfAccounts(ChartOfAccount coa){
coa.getOrganizations().add(this);
chartOfAccounts.add(coa);
}




public String getName() {
return name;
}



public void setName(String name) {
this.name = name;
}




public String getOrganizationCode() {
return organizationCode;
}


public void setOrganizationCode(String organizationCode) {
this.organizationCode = organizationCode;
}


}


<===== Organization mapping ===>
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping

>

<class
name="model.Organization"
table="organization"
>

<id
name="id"
column="organization_id"
type="integer"
>

<generator
class="native"
>

</generator>

</id>

<set
name="chartOfAccounts"
table="coa_organization"
lazy="true"
cascade="save-update"
>

<key
column="organization_id"
>

</key>

<many-to-many
class="model.ChartOfAccount"
column="coa_id"
>

</many-to-many>

</set>

<property
name="name"
type="string"
column="name"
>

</property>

<property
name="organizationCode"
type="string"
column="organization_code"
>

</property>

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 9:22 pm 
Newbie

Joined: Mon Mar 06, 2006 3:33 am
Posts: 2
Hai all,
someone on the spring forum pointed me that it was possible that the file i deploy corrupt, and he was right.
http://forum.springframework.org/showth ... 6&posted=1

fixing my ant task solve this problem.

regards,

mailindra


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.