0
public List<Marki> getMarki()
      {
        List<Marki> markiList = null;
        try {
            Session session = HibernateSession.getSessionFactory().getCurrentSession();
            session.beginTransaction();
            Query q = session.createQuery("from Marki ");
            if ( q != null ) {
                markiList = ( List<Marki> ) q.list();
            }
            // session.getTransaction().commit();
        } catch ( Exception e ) {
            e.printStackTrace();
        }
        return markiList;
 }

Mapping

<hibernate-mapping>
    <class name="bazaMap.Marki" table="marki" schema="public">
        <id name="id" type="int">
            <column name="id" />
            <generator class="assigned" />
        </id>
        <property name="marka" type="serializable">
            <column name="marka" unique="true" />
        </property>
        <set name="modeles" inverse="true">
            <key>
                <column name="markaid" not-null="true" />
            </key>
            <one-to-many class="bazaMap.Modele" />
        </set>
    </class>
</hibernate-mapping>


N



CREATE TABLE marki
(
  id serial NOT NULL,
  marka character varying(32)[],
  CONSTRAINT glowny PRIMARY KEY (id),
  CONSTRAINT marki_marka_key UNIQUE (marka)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE marki
  OWNER TO postgres;

FO: Hibernate: select marki0_.id as id3_, marki0_.marka as marka3_ from public.marki marki0_ INFO: could not read column value from result set: marka3_; could not deserialize SEVERE: org.hibernate.type.SerializationException: could not deserialize at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:217) at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240) at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:82) at org.hibernate.type.SerializableType.get(SerializableType.java:39) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2096) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308) at org.hibernate.loader.Loader.getRow(Loader.java:1206) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580) at org.hibernate.loader.Loader.doQuery(Loader.java:701) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2220) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:912) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) at DataFetcher.getMarki(DataFetcher.java:40)

1.All the Mappings code were generated by NetBeans. Any ideas what could be wrong or even better - how to fix it?

blah "Your post does not have much context to explain the code sections; please explain your scenario more clearly."

4

1 回答 1

1

我敢打赌这是你的问题:

marka character varying(32)[],

你可能不想要一个字符数组。这可能是你想要的:

marka varchar(32),

最后我检查了 Hibernate 不知道如何处理开箱即用的 Postgres 数组,因为很少有 RDBMS 支持它们。

于 2013-01-23T22:39:34.393 回答