Hello,
It's my first post on the Hibernate forum, I hope I'm in the right place..
I use hibernate to display spatial data that are stored in a postgis DB. I use Geomajas like a cartographic framework I would like to use the many-to one relation between a spatial table (plotting) and an alphanumeric table (farm). One farm might have many plots.
So, I defined my java mapping classes :
Farm :
@Entity @Table(name = "farm") public class Farm implements Serializable {
@Id @GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY) @Column(name = "grower_nb") private Integer grower_nb;
@Column (name="lease_nb") private String lease_nb;
public Integer getgrower_nb() { return grower_nb; }
public void setgrower_nb(Integer grower_nb) { this.grower_nb = grower_nb; }
public String getlease_nb() { return lease_nb; }
public void setlease_nb(String lease_nb) { this.lease_nb = lease_nb; } }
Plotting
@Entity @Table(name = "drasa_plotting2011") public class Drasa_Plotting2011 implements Serializable {
@Id @GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY) @Column(name = "gid") private Long id; private String variety; private Double tpha; @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "growernb", nullable = false) private Farm grower; @Type(type = "org.hibernatespatial.GeometryUserType") @Column (name="the_geom") private Geometry geometry;
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public Geometry getGeometry() { return geometry; }
public void setGeometry(Geometry geometry) { this.geometry = geometry; } public String getvariety() { return variety; }
public void setvariety(String variety) { this.variety = variety; } public Double gettpha() { return tpha; }
public void settpha(Double tpha) { this.tpha = tpha; } public Farm getgrower() { return grower; }
public void setFarm(Farm grower) { this.grower = grower; }
}
The configuration file to display associate attributes of a record
<bean class="org.geomajas.configuration.AssociationAttributeInfo"> <property name="label" value="Grower" /> <property name="name" value="grower" /> <property name="editable" value="true" /> <property name="identifying" value="false" /> <property name="type" value="MANY_TO_ONE" /> <property name="feature"> <bean class="org.geomajas.configuration.FeatureInfo"> <property name="dataSourceName" value="postgis.hibernate.server.Farm" /> <property name="identifier"> <bean class="org.geomajas.configuration.PrimitiveAttributeInfo"> <property name="label" value="Grower NB" /> <property name="name" value="grower_nb" /> <property name="type" value="LONG" /> </bean> </property> <property name="attributes"> <list> <bean class="org.geomajas.configuration.PrimitiveAttributeInfo"> <property name="label" value="Lease" /> <property name="name" value="lease_nb" /> <property name="editable" value="true" /> <property name="identifying" value="true" /> <property name="type" value="STRING" /> </bean> </list> </property> </bean> </property> </bean>
And the hibernate.cfg.xml
<hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernatespatial.postgis.PostgisDialect</property>
<property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <mapping class="postgis.hibernate.server.Drasa_Plotting2011" /> <mapping class="postgis.hibernate.server.Farm" /> </session-factory> </hibernate-configuration>
The vector layer displays in my application but when I try to identify a record, I've the following message : " An error occured on the server Unknown entity: grower
org.hibernate.MappingException: org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:704) org.hibernate.impl.SessionImpl.getOuterJoinLoadable(SessionImpl.java:1721) org.hibernate.impl.SessionImpl.list(SessionImpl.java:1687) org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347) org.geomajas.layer.hibernate.HibernateLayer.getAttributes(HibernateLayer.java:320) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) $Proxy24.getAttributes(Unknown Source) org.geomajas.internal.layer.vector.GetAttributesStep.execute(GetAttributesStep.java:53) org.geomajas.internal.layer.vector.GetAttributesStep.execute(GetAttributesStep.java:32) org.geomajas.internal.service.pipeline.PipelineServiceImpl.execute(PipelineServiceImpl.java:87) org.geomajas.internal.service.pipeline.PipelineServiceImpl.execute(PipelineServiceImpl.java:62) org.geomajas.internal.layer.VectorLayerServiceImpl.getAttributes(VectorLayerServiceImpl.java:205) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) $Proxy26.getAttributes(Unknown Source) org.geomajas.command.feature.SearchAttributesCommand.execute(SearchAttributesCommand.java:64) org.geomajas.command.feature.SearchAttributesCommand.execute(SearchAttributesCommand.java:39) sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) $Proxy27.execute(Unknown Source) org.geomajas.internal.service.CommandDispatcherImpl.execute(CommandDispatcherImpl.java:114) org.geomajas.gwt.server.GeomajasServiceImpl.execute(GeomajasServiceImpl.java:74) sun.reflect.GeneratedMethodAccessor114.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562) com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:207) com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243) com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) org.geomajas.gwt.server.GeomajasServiceImpl.service(GeomajasServiceImpl.java:64) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) ......
I've checked my configuraiton files but I don't see where is the error
Do you have any idea about that?
Thanks very much
Geoffroy
|