With the following two classes I am getting the exception:
PropertyNotFoundException: field [club_id] not found on com.bill.googlemaps.domain.Location
I am sure it is a newbie problem but this newbie is stuck.
Any thoughts greatly appreciated.
Code:
Caused by: org.hibernate.PropertyNotFoundException: field [club_id] not found on com.bill.googlemaps.domain.Location
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:122)
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:114)
at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:137)
at org.hibernate.util.ReflectHelper.getter(ReflectHelper.java:83)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:71)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:279)
at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2171)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2148)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2038)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:359)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
at org.hibernate.cfg.Configuration.add(Configuration.java:675)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:483)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:674)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1257)
... 62 more
My Location class:
Code:
@Entity
@Table(name="locations")
public class Location {
public Location() {
super();
}
@Id
@Column(name="id")
private int id;
@ManyToOne()
@JoinColumn(name = "club_id", nullable = false)
private Club club;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Club getClub() {
return club;
}
public void setClub(Club club) {
this.club = club;
}
}
My Club class:
Code:
@Entity
@Table(name="clubs")
public class Club {
public Club() {
super();
}
@Id
@Column(name="id")
private int id;
@OneToMany(mappedBy = "club")
private List<Location> locations;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<Location> getLocations() {
return locations;
}
public void setLocations(List<Location> locations) {
this.locations = locations;
}
}