Обсуждение: postgresql 7.4.6-6, hibernate-2.1.6, jdbc3

Поиск
Список
Период
Сортировка

postgresql 7.4.6-6, hibernate-2.1.6, jdbc3

От
Pavel Jbanov
Дата:
Hi,

I have postgresql 7.4.6-6, hibernate-2.1.6, jdbc3 (pg74.215.jdbc3.jar).
I get this exception:


I have a pretty complex structure, but here I try to do a simple thing:

SomeBean foo = (SomeBean) session.get(SomeBean.class,
primary_key_value);

I have: <property name="show_sql">true</property>, so I tried executing
the query it generated directly, it executed without problems.

--
Pavel Jbanov
http://www.spicesoft.com/~pavel/


Re: postgresql 7.4.6-6, hibernate-2.1.6, jdbc3

От
Pavel Jbanov
Дата:
Sorry, gone unfinished. :/

The exception is:
Caused by: org.postgresql.util.PSQLException: ???????????? Byte f
    at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getByte(AbstractJdbc1ResultSet.java:244)
    at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getByte(AbstractJdbc1ResultSet.java:491)
    at net.sf.hibernate.type.ByteType.get(ByteType.java:18)
    at
net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
    at
net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
    at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
    at net.sf.hibernate.loader.Loader.hydrate(Loader.java:686)
    at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:627)
    at
net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:586)
    at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
    at
net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
    at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
    at
net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
    at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
    at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
    at
net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
    at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
    ... 36 more

What should I look at? Where can be the cause?

Thanks.

> Hi,
>
> I have postgresql 7.4.6-6, hibernate-2.1.6, jdbc3 (pg74.215.jdbc3.jar).
> I get this exception:
>
>
> I have a pretty complex structure, but here I try to do a simple thing:
>
> SomeBean foo = (SomeBean) session.get(SomeBean.class,
> primary_key_value);
>
> I have: <property name="show_sql">true</property>, so I tried executing
> the query it generated directly, it executed without problems.
--
Pavel Jbanov
http://www.spicesoft.com/~pavel/


Re: postgresql 7.4.6-6, hibernate-2.1.6, jdbc3

От
Oliver Jowett
Дата:
Pavel Jbanov wrote:
> Sorry, gone unfinished. :/
>
> The exception is:
> Caused by: org.postgresql.util.PSQLException: ???????????? Byte f
>     at
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.getByte(AbstractJdbc1ResultSet.java:244)

I'd need to see the untranslated exception message to be sure, but..

getByte() expects a numeric value (TINYINT, although SMALLINT/int2 is
the closest mapping in PostgreSQL). You appear to be trying to retrieve
a text/varchar (or possibly boolean) value that can't be parsed as a
numeric value.

(there might be a driver bug here -- the JDBC datatype conversion tables
indicate you can use getByte() on BIT/BOOLEAN, but I'm not sure what the
exact conversion should be)

-O

Re: postgresql 7.4.6-6, hibernate-2.1.6, jdbc3

От
Pavel Jbanov
Дата:
In addition:

the query is:
select contact0_.contact_id as contact_id0_, contact0_.account_id as
account_id0_, contact0_.created as created0_, contact0_.first_name as
first_name0_, contact0_.last_name as last_name0_, contact0_.middle_name
as middle_n6_0_, contact0_.home_phone as home_phone0_,
contact0_.cell_phone as cell_phone0_, contact0_.business_phone as
business9_0_, contact0_.additional_phone as additio10_0_, contact0_.fax
as fax0_, contact0_.email as email0_, contact0_.email2 as email20_,
contact0_.res_address as res_add14_0_, contact0_.res_city as res_city0_,
contact0_.res_country as res_cou16_0_, contact0_.res_postal as
res_postal0_, contact0_.res_province as res_pro18_0_,
contact0_.mail_address as mail_ad19_0_, contact0_.mail_city as
mail_city0_, contact0_.mail_country as mail_co21_0_,
contact0_.mail_postal as mail_po22_0_, contact0_.mail_province as
mail_pr23_0_, contact0_.mail_same as mail_same0_, contact0_.modified as
modified0_ from contact contact0_ where contact0_.contact_id=?

(it was automatically generated by hibernate)

And the table is:
CREATE TABLE contact
(
  contact_id int8 NOT NULL,
  account_id varchar(30) NOT NULL,
  created timestamp NOT NULL,
  first_name varchar(255),
  last_name varchar(255),
  middle_name varchar(255),
  home_phone varchar(255),
  cell_phone varchar(255),
  business_phone varchar(255),
  additional_phone varchar(255),
  fax varchar(255),
  email varchar(255),
  email2 varchar(255),
  res_address varchar(255),
  res_city varchar(255),
  res_country int8,
  res_postal varchar(10),
  res_province varchar(255),
  mail_address varchar(255),
  mail_city varchar(255),
  mail_country int8,
  mail_postal varchar(10),
  mail_province varchar(255),
  mail_same bool,
  modified timestamp NOT NULL,
  CONSTRAINT contact_pkey PRIMARY KEY (contact_id),
  CONSTRAINT "$1" FOREIGN KEY (account_id) REFERENCES account
(account_id) ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH OIDS;


On Tue, 2005-01-25 at 14:20, Pavel Jbanov wrote:
> Sorry, gone unfinished. :/
>
> The exception is:
> Caused by: org.postgresql.util.PSQLException: ???????????? Byte f
>     at
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.getByte(AbstractJdbc1ResultSet.java:244)
>     at
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.getByte(AbstractJdbc1ResultSet.java:491)
>     at net.sf.hibernate.type.ByteType.get(ByteType.java:18)
>     at
> net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
>     at
> net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
>     at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
>     at net.sf.hibernate.loader.Loader.hydrate(Loader.java:686)
>     at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:627)
>     at
> net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:586)
>     at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
>     at
> net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
>     at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
>     at
> net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
>     at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
>     at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
>     at
> net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
>     at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
>     ... 36 more
>
> What should I look at? Where can be the cause?
>
> Thanks.
>
> > Hi,
> >
> > I have postgresql 7.4.6-6, hibernate-2.1.6, jdbc3 (pg74.215.jdbc3.jar).
> > I get this exception:
> >
> >
> > I have a pretty complex structure, but here I try to do a simple thing:
> >
> > SomeBean foo = (SomeBean) session.get(SomeBean.class,
> > primary_key_value);
> >
> > I have: <property name="show_sql">true</property>, so I tried executing
> > the query it generated directly, it executed without problems.
--
Pavel Jbanov
http://www.spicesoft.com/~pavel/


Re: postgresql 7.4.6-6, hibernate-2.1.6, jdbc3

От
Pavel Jbanov
Дата:
Right, I had bool there. I've changed it to bit, now it works.

Thanks.

On Tue, 2005-01-25 at 14:58, Oliver Jowett wrote:
> getByte() expects a numeric value (TINYINT, although SMALLINT/int2 is
> the closest mapping in PostgreSQL). You appear to be trying to retrieve
> a text/varchar (or possibly boolean) value that can't be parsed as a
> numeric value.
>
> (there might be a driver bug here -- the JDBC datatype conversion tables
> indicate you can use getByte() on BIT/BOOLEAN, but I'm not sure what the
> exact conversion should be)
>
> -O

--
Pavel Jbanov
http://www.spicesoft.com/~pavel/


Re: postgresql 7.4.6-6, hibernate-2.1.6, jdbc3

От
Kris Jurka
Дата:

On Wed, 26 Jan 2005, Oliver Jowett wrote:

> (there might be a driver bug here -- the JDBC datatype conversion tables
> indicate you can use getByte() on BIT/BOOLEAN, but I'm not sure what the
> exact conversion should be)
>

It's hard to conceive of using values other than 0/1.

Kris Jurka

Re: postgresql 7.4.6-6, hibernate-2.1.6, jdbc3

От
Oliver Jowett
Дата:
Kris Jurka wrote:
> On Wed, 26 Jan 2005, Oliver Jowett wrote:
>
>>(there might be a driver bug here -- the JDBC datatype conversion tables
>>indicate you can use getByte() on BIT/BOOLEAN, but I'm not sure what the
>>exact conversion should be)
>
> It's hard to conceive of using values other than 0/1.

Isn't 0/-1 more common in the SQL world?

-O