在我的數據庫我有這個表:PGpoint休眠(反)序列化異常
CREATE TABLE base_station
(
MCC INT NOT NULL,
MNC INT NOT NULL,
LAC INT NOT NULL,
CID INT NOT NULL,
type TEXT NOT NULL,
geoposition point NOT NULL,
city TEXT,
date_created DATE,
PRIMARY KEY (CID, MNC, LAC, MCC),
FOREIGN KEY (MNC, LAC, MCC) REFERENCES location_area (MNC, LAC, MCC) ON DELETE CASCADE DEFERRABLE
);
其中geoposition是指向型的。我讀過的PostgreSQL點應被映射到PGpoint,而是試圖做反序列化數據時,我得到這個異常:
org.hibernate.type.SerializationException: could not deserialize
org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)
org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:306)
org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:140)
org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:121)
org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:44)
org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:67)
org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:261)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:257)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:247)
org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:332)
org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2912)
org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1673)
org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1605)
org.hibernate.loader.Loader.getRow(Loader.java:1505)
org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:713)
org.hibernate.loader.Loader.processResultSet(Loader.java:943)
org.hibernate.loader.Loader.doQuery(Loader.java:911)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
org.hibernate.loader.Loader.doList(Loader.java:2526)
org.hibernate.loader.Loader.doList(Loader.java:2512)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2342)
org.hibernate.loader.Loader.list(Loader.java:2337)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:495)
org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:357)
org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
org.hibernate.internal.SessionImpl.list(SessionImpl.java:1269)
org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
pl.elka.networkwatcher.dao.implemented.HibernateDAOImpl.getList(HibernateDAOImpl.java:49)
pl.elka.networkwatcher.managers.BaseStationManager.findAll(BaseStationManager.java:25)
pl.elka.networkwatcher.managers.BaseStationManager$$FastClassByCGLIB$$bbbd79f1.invoke(<generated>)
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
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.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
pl.elka.networkwatcher.managers.BaseStationManager$$EnhancerByCGLIB$$30a97444.findAll(<generated>)
pl.elka.networkwatcher.controllers.MainController.stations(MainController.java:61)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
當我從Hibernate映射刪除geoposition,它工作正常。 這裏是我的一塊實體類:
@Column(name = "geoposition", nullable = false)
private PGpoint geoposition;
我使用PostgreSQL 9.1沒有PostGIS的。 我該如何解決這個問題,讓休眠工作正常?
有沒有使用PostGIS的具體原因是什麼? – TheSteve0
我的項目中不需要PostGIS。唯一的需要是具有單個屬性地理位置而不是兩個:緯度和經度。但似乎不可能這樣做.. – mattis
我也有這個問題。我正在使用hibernate空間。 – Zerkz