Hi ,
I'm using postgreSql 8.3 and i have this table which containt a bytea field .
Code:
CREATE TABLE gallet
(
nom_gallet character varying(20) NOT NULL,
img_gallet bytea,
CONSTRAINT pk_gallet PRIMARY KEY (nom_gallet)
)
hibernate.cfg.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="hibernateClass">
<class
name="Gallet"
table="gallet"
>
<meta attribute="sync-DAO">false</meta>
<id
name="nom_gallet"
type="string"
column="nom_gallet"
>
</id>
<property
name="ImgGallet"
column="img_gallet"
type="java.sql.Blob"
not-null="false"
/>
<set name="InfoModeleAvions" inverse="true">
<key column="nom_gallet"/>
<one-to-many class="InfoModeleAvion"/>
</set>
</class>
</hibernate-mapping>
when i try to insert a new gallet
Code:
Session s=HibernateUtil.currentSession();
Transaction tx = s.beginTransaction();
Gallet g=new Gallet();
File fd = new File("c:\\img.jpg");
FileInputStream fis;
try {
fis = new FileInputStream(fd);
byte[] b = new byte[512];
fis.read(b);
g.setNom_gallet("petit gallet de test");
g.setImgGallet(Hibernate.createBlob(b));
s.save(g);
tx.commit();
HibernateUtil.closeSession();
i get this exception
Code:
org.postgresql.util.PSQLException: ERROR: column "img_gallet" is a bytea but the expression is a bigint
.....
Caused by: java.sql.BatchUpdateException: The batch of 0 insert into Gallet (img_gallet, nom_gallet) values (17,027 small Gallet test) was canceled. GetNextException call to find out the cause.
can you explain me how to solve this problem ?
Thanks.